How Do I Find The Season From The Month + Date? Python
I spent way to much time on this, I'm pretty new to python. If someone could help the get the season from the month, and day that would be great, in the current example I'm just tr
Solution 1:
Don't check every single possible value of month
. Just do an inequality. As norie pointed out, your user inputs are converted to integers anyways so this works perfectly for you.
month = int(input("Enter a month: "))
day = int(input("Enter a day: "))
def season(month):
if (month == 12 or 1 <= month <= 4):
return "winter"
elif (4 <= month <= 5):
return "spring"
elif (6 <= month <= 9):
return "summer"
else:
return "fall"
print(season(month))
Post a Comment for "How Do I Find The Season From The Month + Date? Python"