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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!