May-13-2020, 07:56 PM
Nested if's are a thing to avoid. For a problem like this it often works best to test for all the bad and if you get past that assume the input is good.
if not too_young < age < too_old: print('We don't like babies or or old people') elif salary < 35,000: print('Get a decent job!') elif have_id.lower() != 'y': print('another demeaning remark')Better yet, don't ask further questions if they are already ineligible.
def eligibility(): if input('Do you have a valid license? ').lower() != 'y': print('Sorry, a valid license is required.') return False if int(input('What is your age? ')) > 35: print('Sorry, we only accept applicants 35 or younger') return False # more tests print('Your are eligible') return True