INTERVIEW QUESTION - Conversion of two list into Dictionary Using Python
Vložit
- čas přidán 22. 01. 2020
- INTERVIEW QUESTION - Conversion of two list into Dictionary Using Python
GitHub Link:- github.com/netsetos/python_co...
~-~~-~~~-~~-~
Please watch: "LRU Cache (With Python Code) "
• LRU Cache Implementati...
~-~~-~~~-~~-~
Your Tutorials about python interview questions are really fantastic ,I understood well and i done with my own examples.If dictionary to list what can we do??
Much apperciated. Love your work
Awesome video
My Solution:
def list_to_dict(list1, list2):
dict={}
for i in range(len(list1)):
dict[list1[i]]=list2[i]
print(dict)
Thank you for the amazing solution
Wow ❤️
Thank you
dict = {key:value for (key, value) in zip(list1, list2)}
very useful ...do more videos
Thank you, I will
what is zip fuction and how it works
def list_do_list():
x=[1,2,3]
y=["one","two","three"]
print(dict(zip(x, y, )))
list_do_list()
how to convert the dictionary back to list
use to_list function
dict1={1: 'one', 2: 'two', 3: 'three'}
list1=[]
for i in dict1.items():
list1.extend(list(i))
print(list1)
My Solution:
list1 = ["Naina", "kimi", "sheena"]
list2 = [2356, 4578, 8956]
dict={}
for i in range(0, len(list1)):
dict.update({list1[i] : list2[i] })
print(dict)
Thank you