Why in the case 01 the output prints both the order and the quiz tells that only the first line is printed because the other. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 19

Why in the case 01 the output prints both the order and the quiz tells that only the first line is printed because the other.

https://code.sololearn.com/cOAM7WhSEls4/?ref=app

19th Feb 2018, 6:28 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
6 Answers
+ 19
Thanks anyway Random Coder !¡ But you have to consider that I changed the source code to be the same as in the quiz, and I get different output, and there are no comparisons in the comments !¡
19th Feb 2018, 8:01 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
+ 18
Vucko again, :) because on the question line above does not give enough space for a man to put quality questions. GIVE MORE SPACE FOR MORE CHARACTERS . Anyway, this is just an example of a code and does not work but check what I'm talking about.
19th Feb 2018, 6:36 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
+ 3
because the if statement for seven is inside the if statement for 5 which is not true and so it doesnt run
20th Feb 2018, 12:24 AM
Markus Kaleton
Markus Kaleton - avatar
+ 2
https://code.sololearn.com/cwteM3r4iueC/?ref=app I don't know python, so cant't answer your question, but here is fixed code and there is question in it. Maybe people will understand your question better with fixed code :p
19th Feb 2018, 6:50 PM
Sad
Sad - avatar
+ 2
:p
19th Feb 2018, 8:02 PM
Sad
Sad - avatar
+ 2
It's due to the nested "if"'s in the code. When an "if" statement runs it checks if the condition is true. if the condition is true then it completes the subroutine. in the case 01 example you can see that the argument is true in the first case. So it runs the subroutines "print" and the next "if" which is also true so it runs it's subroutines as well. In the quiz example the first "if" statement is true, so it prints and runs the next "if". This "if" however, returns false. So it exits the subroutine.
25th Feb 2018, 2:51 AM
Dan C
Dan C - avatar