INTERVIEW QUESTION - Conversion of two list into Dictionary Using Python

preview_player
Показать описание
INTERVIEW QUESTION - Conversion of two list into Dictionary Using Python

-~-~~-~~~-~~-~-
Please watch: "LRU Cache (With Python Code) "
-~-~~-~~~-~~-~-
Рекомендации по теме
Комментарии
Автор

My Solution:
def list_to_dict(list1, list2):
dict={}
for i in range(len(list1)):
dict[list1[i]]=list2[i]
print(dict)

techiewithcamera
Автор

dict = {key:value for (key, value) in zip(list1, list2)}

sindhuswrp
Автор

def list_do_list():
x=[1, 2, 3]
y=["one", "two", "three"]
print(dict(zip(x, y, )))

list_do_list()

Didffjbjgha
Автор

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??

srisangeeth
Автор

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)

NISHASINGH-gswh
Автор

l1=['shubhi', 'geek', 'meet', 'reema', 'seema']
l2=[600, 800, 1200, 900]
d1={}


for k, v in zip(l1, l2):
d1[k]=v

print(d1)

shubhimanocha
Автор

I did it like
d={}
L1=[<value>]
L2=[<value>]

for i in range(0, len(L1):
d[L1[i]] = L2[i]

print(d)


simple

devmrnecro
Автор

list1 = ['NAINA', 'KIMI', 'SHEENA']
list2 = [123, 456, 789]

output = {list1[i]: list2[i] for i in range(len(list1))}
print(output)

niraja
Автор

how to convert the dictionary back to list

shareefshaik
Автор

l1=['naina', 'kimi', 'sheena']
l2=[852345, 763567, 691276]
d=dict(zip(l1, l2))
print(d)

Youtuber_