+ 1

How would you get this to output correctly?

num = 10 if num < 5: print("Number is less than 5") if num > 5: print("Number is greater than 5") print("Proceed") Im new to this but im trying to challenge myself. ive tried but cant seem to figure out how to print out both "Number is greater than 5" and afterwards if the statement is correct "Proceed" but if i add the last part of the code thats the only part that outputs if i remove it, the output is no output

4th Apr 2017, 6:09 PM
Seth T
Seth T - avatar
4 Answers
+ 17
Indentation matters in Python! Remove the whitespaces before "if num>5:" This indentation implies that, if the number is less than 5, only then the 2nd condition will be checked.
4th Apr 2017, 6:25 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 18
My pleasure 😊 Since unlike other languages, we can't separate the body of if/for/else/while using curly braces {}, indentation is the only way to handle that. So wrong indentation can change the whole game 😁 And thanks for choosing my answer as best 😊
4th Apr 2017, 6:36 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 2
Omg thank you so much it works!
4th Apr 2017, 6:32 PM
Seth T
Seth T - avatar
+ 2
Yea i see now, i just didnt really understand the indention thing i was unaware that i had to unindent the next if statement inorder for it to check the 2nd if, due to the previous lesson that had the 2 if statements nested. but that clears it up for me tho i feel more comfortable fs, no problem thank you for helping!
4th Apr 2017, 6:40 PM
Seth T
Seth T - avatar