if and if else

Want to learn more? I recommend these Python books: Python for Data Analysis, Python Data Science Handbook, and Introduction to Machine Learning with Python.

Create a variable with the status of the conflict.

  • 1 if the conflict is active
  • 0 if the conflict is not active
  • unknown if the status of the conflict is unknwon
conflict_active = 1

If the conflict is active print a statement

if conflict_active == 1:
    print('The conflict is active.')
The conflict is active.

If the conflict is active print a statement, if not, print a different statement

if conflict_active == 1:
    print('The conflict is active.')
else:
    print('The conflict is not active.')
The conflict is active.

If the conflict is active print a statement, if not, print a different statement, if unknown, state a third statement.

if conflict_active == 1:
    print('The conflict is active.')
elif conflict_active == 'unknown':
    print('The status of the conflict is unknown')
else:
    print('The conflict is not active.')
The conflict is active.