I want to generate all the values in a dictionary to a list.
a={'alpha':1.2,'beta':0.5}
Here I want the output as:
[1.2,0.5]
ls=[]
for i in a.items():
for j in i:
if j==int:
ls.append(j)
Output as
[1.2,0.5]
I want to generate all the values in a dictionary to a list.
a={'alpha':1.2,'beta':0.5}
Here I want the output as:
[1.2,0.5]
ls=[]
for i in a.items():
for j in i:
if j==int:
ls.append(j)
Output as
[1.2,0.5]
Try this ,may help
a={'alpha':1.2,'beta':0.5}
ls=[]
for it in a.values():
ls.append(it)
try this code, similar to yours
ls=[]
for i in a.items():
ls.append(i[1])
print(ls)
best, giulio