[SOLVED] Can you convert a list or tuple to a dictionary in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

[SOLVED] Can you convert a list or tuple to a dictionary in python?

28th Oct 2017, 11:17 AM
Poet🎭
Poet🎭 - avatar
5 Answers
+ 12
Sure, there is a neat zip() method for that. Check it out: https://code.sololearn.com/cXUhNQb5tNW3/?ref=app
28th Oct 2017, 12:03 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 8
You can cast a list() method on it. It will return a list with the dictionary keys as elements.
28th Oct 2017, 2:55 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
Thanks!!!
28th Oct 2017, 1:01 PM
Poet🎭
Poet🎭 - avatar
+ 2
Then how do I turn it back to a list?
28th Oct 2017, 2:00 PM
Poet🎭
Poet🎭 - avatar
+ 2
Cool thanks, you seem to be very knowledgeable about python
28th Oct 2017, 2:57 PM
Poet🎭
Poet🎭 - avatar