Hey,
here’s a problem for you to solve.
list1=['name1_aadhar_124212345678', 'name2_pan_1234hsk453', 'name3_aadhar_432154326543']
write code to get output as follows.
Hey,
here’s a problem for you to solve.
list1=['name1_aadhar_124212345678', 'name2_pan_1234hsk453', 'name3_aadhar_432154326543']
write code to get output as follows.
list1=['name1_aadhar_124212345678', 'name2_pan_1234hsk453', 'name3_aadhar_432154326543']
d = {}
for i in list1:
l = i.split('_')
d[l[0]] = {'id':l[1],'id_num':l[2]}
print(d)
my_dict={}
list2=[]
for i in list1:
list2.append(i.split('_'))
for i in list2:
my_dict[i[0]]=dict()
for j,i in zip(my_dict.values(),list2):
j['id']=i[1]
j['id_num']=i[2]