This is the information that I was given:
Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day.
Ex: If the input is:
April
11
the output is:
Spring
In addition, check if the string and int are valid (an actual month and day).
Ex: If the input is:
Blue
65
the output is:
Invalid
The dates for each season are:
Spring: March 20 - June 20
Summer: June 21 - September 21
Autumn: September 22 - December 20
Winter: December 21 - March 19
This is what I have coded so far:
# Input the month and day
input_month = input()
input_day = int(input())
month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December']
#TODO: write if-else statements to determine if the input is valid. Output the result if input is not valid.
if input_month not in month or input_day > 31:
print('Invalid')
#TODO: write if-else statements to test each month and determine the season of the corresponding date. Output the season.
#Note: pay special care on March, June, September, and December for two possible seasons
if input_month == ('December') and input_day > 20:
if input_month == ('January') and input_day < 32:
if input_month == ('February') and input_day < 29:
if input_month == ('March') and input_day < 20:
print('Winter')
elif input_month == ('March') and input_day > 19:
if input_month == ('April') and input_day < 31:
if input_month == ('May') and input_day < 32:
if input_month == ('June') and input_day < 21:
print('Spring')
elif input_month == ('June') and input_day > 20:
if input_month == ('July') and input_day < 32:
if input_month == ('August') and input_day < 32:
if input_month == ('September') and input_day < 22:
print('Summer')
elif input_month == ('September') and input_day > 21:
if input_month == ('October') and input_day < 32:
if input_month == ('November') and input_day < 31:
if input_month == ('December') and input_day < 21:
print('Autumn')
I don't understand what is going wrong? A nudge in the right direction would be GREATLY appreciated