Question: age = int(input('What is your age? ')) if age < 0: print('You can't be negative years old!') elif age > 120: print('You're pretty old to
age = int(input('What is your age? ')) if age < 0: print('You can\'t be negative years old!') elif age > 120: print('You\'re pretty old to be going to college.') elif age < 10: print('You\'re pretty young to be going to college.') favColor = input('What is your favorite color? ')
Notice that there is no need to have an else part in an if statement, even when it includes one or more elif parts.
Notice also, that the "pretty young" response only gets added when the person is between 0 and 10. Well -3 is less than 10, why doesn't it print out the "pretty young" response if the user inputs "-3"? Nerd alert: This paragraph has a logical error in it.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
