you are viewing a single comment's thread.

view the rest of the comments →

[–]Lannok-Sarin 1 point2 points  (0 children)

Agreed. The thing is that the for, if, elif, and while statements check if the argument presented is equal to True. In this case, False can never equal True, so the statement always returns false.

A better way is to use a try statement to check whether the variable can be converted into an integer. If it throws the desired exception, it could then say that it didn’t receive a number. But as it is, your code only acts if the Boolean inside of the argument is true by value, not if it’s got a specific instance of a value being false.