Hi!
I've a qusetion about the program in chpater 6, page 184.
In last line where else condition is lying:
else:
credit_card = input("Credit card number: ")
save_transaction(prices[choice - 1], credit_card,items[choice-1])
What happens when save_transaction function is run? Please answer by focusing on given argument :
(prices[choice - 1], credit_card,items[choice-1])
Thanks friend!
Hi TheFuture, is that hard to understand ? which part of it?
Anyway, if the customer don't choose quit which is in the if condition the else clause will run.
That means the customer wants to buy something.
In the else part , the save_transaction() will run; with the choice, price of choice and credit card number the customer entered.
Well, choice-1 is used here because python start indexing list/string/tuple etc at 0 (zero). Here is a link if you want to know why?! (Mr. Guido van Rossum written about it himself). But it will be difficult to understand if you don't know a little bit of computer science, algorithms, data structures etc. You may not be able to comprehend and may be like "What the hell is he talking about??!!" 
Guido van Rossum on why python start index at 0 (zero)
Anyway, let's get back to the program. You give choice to customer as 1,2,3... by using option=1 in the while loop, that is starting from 1. Obviously, in day to day life customers don't expect to encounter something like choice no. 0. 
So, now the function is called and the input customer provided are given as arguments to the save_transaction(price,credit_card,description).
where input to price argument is prices[choice-1]
input to credit_card argument is the credit_card number entered.
and input to description argument is the name of thing customer purchased,i.e., items[choice-1]
Now, the save_transaction() will write these above details to a file.

Edited by #TM#, 18 August 2015 - 11:07 PM.