0

if

If 1 + 1 == 2: If 2 * 2 == 8: Print ("if") Else: Print ("else") So the correct answer (according to sololearn and others) is else. But when I try to prove it, by putting the exact code into Code Playground it gives no output. Why is that? Can anyone explain it? Wow! I'm such a dummy! OK, now it works in Code Playground lol. Sorry I didn't answer Rafik, but i couldn't see your answer for some reason. I'm happy now I've proved to myself that it works :)

11th Jan 2018, 8:52 PM
Chris
4 Answers
+ 2
else
11th Jan 2018, 8:30 PM
rafik
+ 1
else
11th Jan 2018, 8:30 PM
rafik
+ 1
# That's why indentation in Python is important: if 1 + 1 == 2: if 2 * 2 == 8: print ("if") else: print ("else") # will result in no output, but: if 1 + 1 == 2: if 2 * 2 == 8: print ("if") else: print ("else") # will output 'else' (as expected, contraly to the first one quoted in your question)... # Anyway, be carreful of keywords case: 'print' is not 'Print', 'else' not 'Else', and so on ;)
12th Jan 2018, 6:00 AM
visph
visph - avatar
0
else
9th Nov 2022, 5:24 AM
kinzang namgay
kinzang namgay - avatar