0
month = (input('Enter the month (first 3 letters): '))
if month == ('Dec' or 'Jan' or 'Feb'):
    season = ('Summer')     
elif month == ('Mar' or 'Apr' or 'May'):
    season = ('Autumn')
elif month == ('Jun' or 'Jul' or 'Aug'):
    season = ('Winter')
elif month == ('Sep' or 'Oct' or 'Nov'):
    season = ('Spring')
else:
    season = ('not real') 
print('The month of',month,'is',season,)

I don't know why this isn't working. It came back saying season isn't defined. It works for the first result of each. Dec, Mar, Jun, Sep for example. Help please :)

  • I have an idea... https://stackoverflow.com/questions/15112125/how-do-i-test-one-variable-against-multiple-values – cs95 Sep 15 '17 at 06:25
  • Open a Python prompt, enter `('Dec' or 'Jan' or 'Feb')`, press Enter and you might get an idea. – Klaus D. Sep 15 '17 at 06:26
  • 1
    And BTW: mapping values to other values is best done with a dictionary. – Klaus D. Sep 15 '17 at 06:29
  • And another BTW: You have a "parentheses overflow". `season = 'Summer'` is enough, there's no need to write `season = ('Summer')`. – Matthias Sep 15 '17 at 07:07

0 Answers0