Add to this code the numbering of all group_list values from 1 dct = convert_to_dict(students) def group_list(dct, gr): group_list = [] for k, v in dct.items(): if gr in v: group_list.append(' '.join(dct[k][0:3])) group_list.sort() return group_list group_list(dct, 'BST161')
def group_list(dct, gr): group_list = [] for k, v in dct.items(): if gr in v: group_list.append(' '.join(dct[k][0:3])) group_list.sort() for i, n in enumerate(group_list): print('{}. {}'.format(i+1, n)) group_list(dct, 'BST161') # output 1. A. García de Leon 2. A. Martínez Martínez 3. A. Romero de la Fuente 4. C. Ramírez de Cartagena 5. E. González Gómez 6. F. García León 7. H. Solís Ortíz 8. J. Carlos 9. J. Fernández 10. J. Muñoz Solís 11. L. González Gómez