+ 2

Can someone help with this Python code?

So I am making this code (link below), and I figured out if and else statements can only show one condition... So what can i do to make them show multiple? Thanks. https://code.sololearn.com/coMmX3N6XmRj/#

25th Sep 2018, 12:45 AM
DrChicken24
DrChicken24 - avatar
1 Antwort
+ 3
It only runs one section because you used 'elif', which means only test if all previous conditions failed. So, change 'elif's to regular 'if's - so each condition is tested independently. Then you have a section to be executed if all conditions failed. The 'if's themselves can't solve this, because the conditions are independent. But you can add a boolean variable, say 'failed', which starts as True, and is set to False inside each 'if' clause. Then you can change the last 'else' to an 'if' which tests only this boolean variable.
25th Sep 2018, 1:31 AM
Emerson Prado
Emerson Prado - avatar