Help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help

In the if-statements lesson in Module 2, the very last question, I answered it as seven since that's what it should be. But instead they said the answer was three. What mistake did I make?

31st Jul 2019, 6:29 AM
Soham Mukherjee
Soham Mukherjee - avatar
3 Answers
+ 1
You mean like this? num=7 if num>3 print("3") if num<5 print("5") if num==7 print("7") Thats because the identitation in here. Here after the first if statement there was a space in the next if statement. if num>3 print("3") if num<5 ^space In python an most other programming language, that space mean the second if statement is a part of the first if statement. This behavior called nested if statement. This mean if the previous if statement need to be true, if not (false) the program will not execute the next code.
31st Jul 2019, 7:54 AM
Early
Early - avatar
0
hello :) what language and course are you talking about? you can always check in the comments about/after that question because more people will probably have written about it also it might be handy to post the code here if you really can’t figure it out. let us know. good luck
31st Jul 2019, 7:37 AM
Brave Tea
Brave Tea - avatar
0
Ok, thanks!
31st Jul 2019, 8:08 AM
Soham Mukherjee
Soham Mukherjee - avatar