Generation

generate functionMon, 26 Dec 2022

Write a function that takes a group number and outputs a numbered and alphabetically ordered list (surnames, first names, patronymics) of all students in that group from the dictionary dct. dct = {'0001': ['Antonov', 'Anton', 'Igorevich', '20.08.2009', 'BST161'], '1102': ['Bogov', 'Artem', 'Igorvich', '25.01.2010', 'BST162'], '0333': ['Glagoleva', 'Anastasia', 'Nikolaevna', '11.07.2009', 'BST163'], '4004': ['Potapov', 'Dmitry', 'Stanislavovich', '14.02.2012', 'BST161'], '0045': ['Bokov', 'Igor', 'Kharitonovich', '02.06.2009', 'BST161'], '0096': ['Vasilkov', 'Valentin', 'Sergeevich', '20.03.2009', 'BST164'], '0607': ['Siropova', 'Violetta', 'Eduardovna', '28.05.2010', 'BST162']}

def func_name(group_number, dct): students = [] for key, value in dct.items(): if value[4] == group_number: students.append(value) students.sort(key=lambda x: x[0]) for index, student in enumerate(students): print(index, student[0], student[1], student[2]) func_name('BST162', dct)

Questions about programming?Chat with your personal AI assistant