Dictionary->List/Sets conversion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Dictionary->List/Sets conversion

What is the best way to convert dictionaries to list and parse them based on values

6th Jun 2020, 12:30 AM
Munib Ur Rahman
Munib Ur Rahman - avatar
3 Answers
+ 8
You can use standard functions dict.items() dict.keys() dict.values()
6th Jun 2020, 3:49 AM
Tibor Santa
Tibor Santa - avatar
+ 4
I don't know if this is the best way, but it may help dic = {1: 'a', 2: 'b', 3: 'c', 4: 'd' } lst = [] for i in dic: lst.append(dic[i]) print(lst)
6th Jun 2020, 3:03 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
https://www.sololearn.com/Discuss/2332053/?ref=app I wanted to know of wr can solve this probpem in multiple ways
6th Jun 2020, 6:09 AM
Munib Ur Rahman
Munib Ur Rahman - avatar