Conditional statements


Great. One problem we had was that the user did not see anything when the condition was not met. Let's change that.

john_age = 25
user_age = input('How old are you?')

if int(user_age) > john_age:
  print('You are older than John.')
  print('You are not older than John.')

An else block that follows an if statement means: when the condition is not met (i.e., when the condition returns False), do the following.

Note how the lines with if and else are not indented. That's very important. The lines after if and else are indented – they start with two spaces, and the actual code follows the two spaces.


Modify your program so that it shows the following sentence when the height is not more than 185 centimeters: You are not very tall.

Stuck? Here's a hint!

Add an else: statement on a new line, and then add a print() instruction. Remember about indentation!