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 group_list(grnum): group_list = [] for key in dct: if grnum in key: group_list.append(' '.join(dct[key][0:3])) group_list.sort() return group_list group_list('BST161')

Questions about programming?Chat with your personal AI assistant