im having trouble with the function bellow where i need to check if the 'key' input is already in the function parameter. only if the 'key' is already in the parameter that is passed my else should be returned. but it happens that the else is beeing returned everytime, and if the 'key' is already in the function parameter my else is returned 2 time.
def change_data(aux):
key = input('Enter the name of the item you want to change the registration:')
for i in aux:
if i['Name'] == key:
value= input('Enter the information for the item you want to change:')
new_value = input('Enter the new data:')
if key == i['Name'] and (value == 'Name' or value == 'name'):
i['Name'] = new_value
elif key == i['Name'] and (value == 'Quantity' or value == 'quantity'):
i['Quantity'] = float(new_value)
elif chave == i['Name'] and (value == 'Cost' or value == 'cost'):
i['Cost'] = float(new_value)
elif chave == i['Name'] and (value == 'Sell' or value == 'sell'):
i['Sell'] = float(new_value)
else:
print('Item not found.')
I've tryed implementing new functions and even doing a new function just to check if the key was already in the parameter, but didn'g got any luck.