INTERVIEW QUESTION - Conversion of two list into Dictionary Using Python
HTML-код
- Опубликовано: 12 сен 2024
- INTERVIEW QUESTION - Conversion of two list into Dictionary Using Python
GitHub Link:- github.com/net...
~-~~-~~~-~~-~
Please watch: "LRU Cache (With Python Code) "
• LRU Cache Implementati...
~-~~-~~~-~~-~
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
dict = {key:value for (key, value) in zip(list1, list2)}
def list_do_list():
x=[1,2,3]
y=["one","two","three"]
print(dict(zip(x, y, )))
list_do_list()
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??
l1=['shubhi','geek','meet','reema','seema']
l2=[600,800,1200,900]
d1={}
for k,v in zip(l1,l2):
d1[k]=v
print(d1)
list1 = ['NAINA', 'KIMI', 'SHEENA']
list2 = [123, 456,789]
output = {list1[i]: list2[i] for i in range(len(list1))}
print(output)
Much apperciated. Love your work
very useful ...do more videos
Thank you, I will
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)
Liked your solution.
Awesome video
Wow ❤️
Thank you
what is zip fuction and how it works
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)
Thank you