I would like to go through as long as a list composed of values and keys is nonzero, just add values (values) in a list? The code I have is this:
hey = ['item1', 'item2', 'item3', 'item4']
print("hey", hey)
lol = [32, 54, 56, 64]
print("lol", lol)
lil = dict(zip(lol, hey))
print("lil: ",lil)
pop = list(zip(lil.values(), lil.keys()))
print("pop sem ordenar: ", pop)
sorted(pop, reverse=True)
print("pop ordenado: ", pop)
#for i in lil:
# print("i: ",i)
# print("lil[i]: ", lil[i])
max_value = max(pop)
print("max_value: ", max_value)
novo_lil = lil[max_value[1]]
del lil[max_value[1]]
print("lil nova: ",lil)
I tried to do this, but it did not work:
hey = ['item1', 'item2', 'item3', 'item4']
print("hey", hey)
lol = [32, 54, 56, 64]
print("lol", lol)
lil = dict(zip(lol, hey))
print("lil: ",lil)
pop = list(zip(lil.values(), lil.keys()))
print("pop sem ordenar: ", pop)
sorted(pop, reverse=True)
print("pop ordenado: ", pop)
#for i in lil:
# print("i: ",i)
# print("lil[i]: ", lil[i])
max_value = max(pop)
while not(lil[max_value[1]]):
print("max_value: ", max_value)
novo_lil = lil[max_value[1]]
del lil[max_value[1]]
print("lil nova: ",lil)
Can anyone help me? What I'm actually doing is sorting a dict and then I just add the values of it into a list, just that.