forked from pablorus/Python_lessons_basic
-
Notifications
You must be signed in to change notification settings - Fork 447
Expand file tree
/
Copy pathhw02-3.py
More file actions
25 lines (25 loc) · 1.03 KB
/
hw02-3.py
File metadata and controls
25 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Задача-3: Пользователь вводит месяц в виде целого числа от 1 до 12.
# Сообщить к какому времени года относится месяц (зима, весна, лето, осень).
# Напишите решения через list и через dict.
number = int(input("Enter month number: "))
if number <= 12 and number >= 1:
month_dict = {1: 'January',
2: 'February',
3: 'March',
4: 'April',
5: 'May',
6: 'June',
7: 'Jule',
8: 'August',
9: 'September',
10: 'October',
11: 'November',
12: 'December'}
month_list = list(month_dict.values())
for i, el in enumerate(month_list):
if i == number-1:
print(f"Month from list is {month_list[i]}")
break
print(f"Month from dict is {month_dict[number]}")
else:
print("You made a mistake")