|
@@ -1,21 +1,21 @@
|
|
|
|
|
|
-a = [42, 23, 66, 42, 93, 47, 30]
|
|
|
-b = 'dsf aaerwq dfasdf '
|
|
|
-c = ('sdf', 'sdqwet', 'ghetrertg')
|
|
|
+# a = [42, 23, 66, 42, 93, 47, 30]
|
|
|
+# b = 'dsf aaerwq dfasdf '
|
|
|
+# c = ('sdf', 'sdqwet', 'ghetrertg')
|
|
|
|
|
|
# метод .sort возвращает None
|
|
|
-new_list = a
|
|
|
-new_list = new_list.sort()
|
|
|
+# new_list = a
|
|
|
+# new_list = new_list.sort()
|
|
|
# print(new_list)
|
|
|
|
|
|
# Принимает любую итерабельную последовательность
|
|
|
# Не изменяет начальную коллекцию
|
|
|
# Возвращает список
|
|
|
-sorted(a)
|
|
|
+# sorted(a)
|
|
|
|
|
|
|
|
|
-sorted_string = sorted(b, reverse=True)
|
|
|
-sorted_tuple = sorted(c)
|
|
|
+# sorted_string = sorted(b, reverse=True)
|
|
|
+# sorted_tuple = sorted(c)
|
|
|
|
|
|
# print(sorted_string)
|
|
|
# print(sorted_tuple)
|
|
@@ -23,13 +23,13 @@ sorted_tuple = sorted(c)
|
|
|
|
|
|
|
|
|
# Сортировка будет происходить по двум признакам последовательно
|
|
|
-def foo(x):
|
|
|
- return x%10, x//10%10
|
|
|
+# def foo(x):
|
|
|
+# return x%10, x//10%10
|
|
|
|
|
|
# print(sorted(a, key=foo))
|
|
|
|
|
|
|
|
|
-my_list_1 = ['ZZZ 5', 'aaa 7', 'BBB 23', 'www 45', 'EEE 5', 'ddd 5']
|
|
|
+# my_list_1 = ['ZZZ 5', 'aaa 7', 'BBB 23', 'www 45', 'EEE 5', 'ddd 5']
|
|
|
|
|
|
# print(sorted(my_list_1, key = str.lower))
|
|
|
# print(sorted(my_list_1, key = lambda x: (int(x.split()[1]), x.split()[0].lower() )))
|
|
@@ -39,9 +39,9 @@ my_list_1 = ['ZZZ 5', 'aaa 7', 'BBB 23', 'www 45', 'EEE 5', 'ddd 5']
|
|
|
|
|
|
# subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Physics', 93),('History', 82)]
|
|
|
|
|
|
-subject_marks = [('English', 88), ('Science', 90), ('Maths', 88),
|
|
|
- ('Physics', 93), ('History', 78), ('French', 78),
|
|
|
- ('Art', 78), ('Chemistry', 88), ('Programming', 91)]
|
|
|
+# subject_marks = [('English', 88), ('Science', 90), ('Maths', 88),
|
|
|
+# ('Physics', 93), ('History', 78), ('French', 78),
|
|
|
+# ('Art', 78), ('Chemistry', 88), ('Programming', 91)]
|
|
|
|
|
|
# subject_marks = sorted(subject_marks, key = lambda x: x[1])
|
|
|
# for key, value in subject_marks:
|
|
@@ -59,15 +59,15 @@ subject_marks = [('English', 88), ('Science', 90), ('Maths', 88),
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
-models = [{'make': 'Nokia', 'model': 216, 'color': 'Black'},
|
|
|
- {'make': 'Mi Max', 'model': 2, 'color': 'Gold'},
|
|
|
- {'make': 'Samsung', 'model': 7, 'color': 'Blue'},
|
|
|
- {'make': 'Apple', 'model': 10, 'color': 'Silver'},
|
|
|
- {'make': 'Oppo', 'model': 9, 'color': 'Red'},
|
|
|
- {'make': 'Huawei', 'model': 4, 'color': 'Grey'},
|
|
|
- {'make': 'Honor', 'model': 3, 'color': 'Black'}]
|
|
|
+# models = [{'make': 'Nokia', 'model': 216, 'color': 'Black'},
|
|
|
+# {'make': 'Mi Max', 'model': 2, 'color': 'Gold'},
|
|
|
+# {'make': 'Samsung', 'model': 7, 'color': 'Blue'},
|
|
|
+# {'make': 'Apple', 'model': 10, 'color': 'Silver'},
|
|
|
+# {'make': 'Oppo', 'model': 9, 'color': 'Red'},
|
|
|
+# {'make': 'Huawei', 'model': 4, 'color': 'Grey'},
|
|
|
+# {'make': 'Honor', 'model': 3, 'color': 'Black'}]
|
|
|
|
|
|
-models = sorted(models, key=lambda x: x.get('color'))
|
|
|
+# models = sorted(models, key=lambda x: x.get('color'))
|
|
|
|
|
|
# for i in models:
|
|
|
# print("Производитель: ", i.get('make'), ", модель: ", i.get('model'), ", цвет: ", i.get('color'), sep='')
|
|
@@ -112,11 +112,41 @@ models = sorted(models, key=lambda x: x.get('color'))
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
-print(type(input().split()))
|
|
|
+# print(type(input().split()))
|
|
|
|
|
|
# my_dict = {}
|
|
|
# n = input()
|
|
|
# for i in range(n):
|
|
|
# st = input().split()
|
|
|
|
|
|
-
|
|
|
+def sort_1():
|
|
|
+ fone_book = {}
|
|
|
+ req_list = []
|
|
|
+ rec_cnt = int(input())
|
|
|
+ for i in range(rec_cnt):
|
|
|
+ record = input().split()
|
|
|
+ if record[1] not in fone_book.keys():
|
|
|
+ fone_book[record[1]] = [record[0]]
|
|
|
+ else:
|
|
|
+ tmp = fone_book[record[1]]
|
|
|
+ tmp.append(record[0])
|
|
|
+ fone_book[record[1]] = tmp
|
|
|
+
|
|
|
+ req_cnt = int(input())
|
|
|
+ for i in range(req_cnt):
|
|
|
+ req_list.append(input())
|
|
|
+ for i in req_list:
|
|
|
+ if i in fone_book.keys():
|
|
|
+ print(*fone_book[i])
|
|
|
+ else:
|
|
|
+ print('Неизвестный номер')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ print(fone_book)
|
|
|
+ print(req_list)
|
|
|
+
|
|
|
+sort_1()
|
|
|
+
|
|
|
+# test_list = ['1', '2', '3']
|
|
|
+# print(*test_list)
|