create a dictionary having keys as words in alphabetical order in SENTENCE and values as length of words in the respective keys | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

create a dictionary having keys as words in alphabetical order in SENTENCE and values as length of words in the respective keys

create a dictionary having keys as words in alphabetical order in SENTENCE and values as length of words in the respective keys. can anybody help for this problem statement? i wrote code for counting length of string but don't know how make dictionary. list=["buyg","huh","jhjjiows","iojajs"] new_list=[] for item in list: len_list_item =len(item) new_list.append(len_list_item) print(new_list) dic={}

3rd Aug 2021, 4:11 PM
Gouri Shinde
Gouri Shinde - avatar
1 Answer
+ 3
list=["buyg","huh","jhjjiows","iojajs"] list.sort() print({i:len(i) for i in list})
3rd Aug 2021, 4:18 PM
Abhay
Abhay - avatar