- Define A Function Named Create Usernames Dictionary Usernames List Which Takes A List Of Usernames As A Parameter And 1 (26.41 KiB) Viewed 14 times
Define a function named create_usernames_dictionary (usernames_list) which takes a list of usernames as a parameter and
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Define a function named create_usernames_dictionary (usernames_list) which takes a list of usernames as a parameter and
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) 1 ['dsmi001'] for key in sorted(a_dict): 2 ['pwong002¹] print(key, a dict[key]) 3 ['dsmi023¹] 4 ['dng134', 'mgra734'] 5 ['bcar735¹] 6 ['kng126¹] 7 [] 8 [] 9 []