Python Practice › If-Else Programs › Program 38
Season from a month
Write a Python program that reads a month name and prints its season (Indian seasons: Winter Dec-Feb, Summer Mar-May, Monsoon Jun-Sep, Post-monsoon Oct-Nov).
Input
"February", "May", "August", "October"
Output
February -> Winter May -> Summer August -> Monsoon October -> Post-monsoon
Approach
- Check which group of months contains the input.
Solution
def season(month): month = month.capitalize() if month in ("December", "January", "February"): return "Winter" elif month in ("March", "April", "May"): return "Summer" elif month in ("June", "July", "August", "September"): return "Monsoon" elif month in ("October", "November"): return "Post-monsoon" return "Unknown month" for m in ["February", "May", "August", "October"]: print(m, "->", season(m))Output
February -> Winter May -> Summer August -> Monsoon October -> Post-monsoon
Line by line
Lines 3-10
Each elif checks one season’s months.
Line 11
A final return covers anything that matched no season.
Note
The original sample said February is Summer. Season boundaries vary by country; this solution uses the common Indian classification with February in Winter.
Learn the concept
New to this topic? Read the lesson, then come back.