I suppose you mean something like this:
monthsBySeason = { 'winter': [12, 1, 2], 'spring': [3, 4, 5], 'summer': [6, 7, 8], 'autumn': [9, 10, 11] } userInput = int(input()) userOutput = '' for season in monthsBySeason: if userInput in monthsBySeason[season]: userOutput = season.capitalize() break else: userOutput = 'There is no such month' print(userOutput)
I also want to draw your attention to the fact that some, especially Europeans, like to consider the onset of a new season differently. In this regard, here is another example .
You can also take the following array for the season "map":
[1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 1]
Here indices will play a special role - zero and the first is Winter, the 2nd / 3rd / 4th is Spring. Etc. Then you can get something like this:
month = int(input()) seasons = ['Winter', 'Spring', 'Summer', 'Autumn'] monthsBySeason = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 1] if month < 1 or month > 12: print('There is not such month') else: print(seasons[monthsBySeason[month - 1] - 1])