Jul-05-2018, 09:58 PM
Look at your conditionals and follow the numbers through.
If you enter 8, it trips the first conditional, but not the second conditional, so the else is triggered. The else clause only cares about the most recent if clause (the second one). A solution here would be to change else to
If you enter 120, that is greater than 112, so it triggers the second if clause, which means the else is not triggered. So you need to change the if clause to prevent that.
Two things to note: You have not covered the situation of an age less than zero. That means you probably want to make the else clause into an if clause. Second, these two are equivalent:
If you enter 8, it trips the first conditional, but not the second conditional, so the else is triggered. The else clause only cares about the most recent if clause (the second one). A solution here would be to change else to
elif age > 112
, or if age > 112
if you haven't covered elif yet.If you enter 120, that is greater than 112, so it triggers the second if clause, which means the else is not triggered. So you need to change the if clause to prevent that.
Two things to note: You have not covered the situation of an age less than zero. That means you probably want to make the else clause into an if clause. Second, these two are equivalent:
if age > 70 and age <=112: print("How did you live so long?") if 70 < age <=112: print("How did you live so long?")It's called chaining your comparisons.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures