Question concerning Conditional Statements


#1

I was just wondering that if you have these three conditional statements:

if number / 4 == 3:

Do this

elif number 4 + number == 16:

Do this

else:

Do this

And you have a number = 12 and it satisfies both the if and elif. What would happen? How would Python interpret this? Would it just go line by line and if it satisfies the if statement then will it go into the if suite but if it doesn't. It will go to the elif or else suites?


#2

Whatever condition is first that is satisfied, gets executed. so since

is the first thing in the conditional statement, because it evaluates true, it is executed. Does that make since? If not I can come up with an example demonstrating it. :slight_smile:


#3


#4

Thank you. I appreciate your help but for lines 32 to 41. When you execute your last try (4 trys), ends up giving you the reason why the the guess_row & column are wrong and tells you "Game Over" assuming you get it wrong. But the if / elif / and else come before the last if statement. How come it prints one of the 3 conditional statements and then the last if?


#5

Right now it looks like the last if statement isn't nested correctly. Indent lines 40 and 41 once more. This will nest the if statement inside of the else statement on line 37 and should fix that issue. Does that make since?


#6

Thank you very much.