Page 1 of 1

in python please:

Posted: Tue May 24, 2022 8:23 am
by answerhappygod
in python please:
In Python Please 1
In Python Please 1 (33.4 KiB) Viewed 13 times
Define a function named create_usernames_dictionary (usernames_list) which takes a list of usernames as a parameter and creates a dictionary. The keys consist of integers and the values are lists of unique usernames where the last digit of each username is equal to the key value. The lists of unique words must be in sorted alphabetical order. Note: A username contains 3 or 4 letters followed by 3 digits. You can assume the list is not empty. For example: Test Result a_list = ['dsmi001', 'dsmi023', 'pwong002', 'kng126', 'mgra734', 'bcar735', 'dng134¹] [] a_dict = create_usernames_dictionary(a_list ) for key in sorted (a_dict): print(key, a dict[key]) 1 ['dsmi001'] 2 ['pwong002'] 3 ['dsmi023¹] 4 ['dng134', 'mgra734'] 5 ['bcar735¹] 6 ['kng126¹] 7 [] 8 [] 9 []