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 11the output is:
SpringIn addition, check if the string and int are valid (an actual month and day).
Ex: If the input is:
Blue 65the output is:
InvalidThe 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
Here is my code:
input_month = input()
input_day = int(input())
if input_month == "September" and input_day > 21:
print("Autumn")
elif input_month == "September" and input_day <= 21:
print("Summer")
elif input_month == "October":
print("Autumn")
elif input_month == "November":
print("Autumn")
if input_month == "December" and input_day >= 21:
print("Winter")
elif input_month == "December" and input_day <= 20:
print("Autumn")
elif input_month == "January":
print("Winter")
elif input_month == "February":
print("Winter")
if input_month == "March" and input_day >= 20:
print("Spring")
elif input_month == "March" and input_day <= 19:
print("Winter")
elif input_month == "April":
print("Spring")
elif input_month == "May":
print("Spring")
if input_month == "June" and input_day >= 21:
print("Summer")
elif input_month == "June" and input_day <= 20:
print("Spring")
elif input_month == "July":
print("Summer")
elif input_month == "August":
print("Summer")
else:
print("Invalid")
It's giving me a few errors:
1: Compare output
0 / 1
Output differs. See highlights below.
Special character legend
Input
April
11
Your output
Spring
Invalid
Expected output
Spring
2: Compare output
0 / 2
Output differs. See highlights below.
Special character legend
Input
March
3
Your output
Winter
Invalid
Expected output
Winter
4: Compare output
0 / 1
Output differs. See highlights below.
Special character legend
Input
February
39
Your output
Winter
Invalid
Expected output
Invalid
6: Compare output
0 / 1
Output differs. See highlights below.
Special character legend
Input
November
7
Your output
Autumn
Invalid
Expected output
Autumn
7: Compare output
0 / 1
Output differs. See highlights below.
Special character legend
Input
September
31
Your output
Autumn
Invalid
Expected output
Invalid
8: Compare output
0 / 1
Output differs. See highlights below.
Special character legend
Input
December
-1
Your output
Autumn
Invalid
Expected output
Invalid