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
When I execute the code it gives me invalid 4 times. I don't know what I'm doing wrong can someone help me?
My Code:
input_month = input()
input_day = int(input())
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
if input_month not in months:
print('Invalid')
else:
if (input_month == 'March' or input_month == 'April' or input_month == 'May' or input_month == 'June') and (
input_month == 'March' and input_day > 19 or input_month == 'June' and input_day <= 20):
print('The season is spring')
else:
print("Invalid")
if (input_month == 'June' or input_month == 'July' or input_month == 'August' or input_month == 'September') and (
input_month == 'June' and input_day > 20 or input_month == 'September' and input_day <= 21):
print('The season is Summer')
else:
print("Invalid")
if ((
input_month == 'September' or input_month == 'October' or input_month == 'November' or input_month == 'December')
and (input_month == 'September' and input_day > 21 or input_month == 'June' and input_day <= 20)):
print('The season is Autumn')
else:
print("Invalid")
if (
input_month == 'December' or input_month == 'January' or input_month == 'February' or input_month == 'March') \
and (input_month == 'December' and input_day > 20 or input_month == 'March' and input_day <= 19):
print('The season is Winter')
else:
print("Invalid")