I have a txt file with the following data:
buy apples 20
buy oranges 15
sold bananas 5
sold bananas 5
sold pears 8
I wrote a program to print out the total number of bananas sold, however I keep getting the error
cannot unpack non-iterable builtin_function_or_method object
How do I fix this issue?
with open("update.txt") as openfile:
for line in openfile:
action, fruit, quantity = line.split
if action == 'sold':
print(f"{fruit} {quantity}")
The output should be:
bananas 10
pear 8
line.split(" ")