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

4th Dec 2017, 12:55 AM
Vincent
Vincent - avatar
5 Respostas
+ 1
https://code.sololearn.com/cn4f625327VZ/?ref=app you can only return 1 object, so tuple yor results, or return only the subtotal
4th Dec 2017, 2:08 AM
Amir Galanty
Amir Galanty - avatar
+ 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.
4th Dec 2017, 2:18 AM
Echo One
Echo One - avatar
0
vincent tried to return two integers.
4th Dec 2017, 4:57 AM
Amir Galanty
Amir Galanty - avatar
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.
6th Dec 2017, 2:39 PM
Vincent
Vincent - avatar
0
I figured it out. Thank you all for your help
7th Dec 2017, 12:48 AM
Vincent
Vincent - avatar