0
Pass subtotal through each function so it updates until termination. Total is given at termination.
Okay. I've been working on this for a week and I still can't figure out how to pass subtotal through each function. I'm trying to get the subtotal to update after each selection, and for the total amount to be given when the program is terminated. https://code.sololearn.com/cK7HDYkG3WB8/?ref=app
5 Réponses
+ 1
https://code.sololearn.com/cn4f625327VZ/?ref=app
you can only return 1 object, so tuple yor results,
or return only the subtotal
+ 1
Ok after a a quick look, you're returning tuples correct?
Simply add a new variable called total
Result below is optional, you determine how you want to handle it
Then result = coke() or any other
total += result[0]
NumOfItems += result[1]
Then if case 5 is called:
Print total
Update: I believe, returning multiple values gives you a tuple automatically. You can then access specific values like an array.
0
vincent tried to return two integers.
0
I'm trying to get it to show the updated subtotal after each entry, not just at the end. I get the correct total amount after the program is terminated, but it only recognizes the local subtotal for each entry.
0
I figured it out. Thank you all for your help