On 09/10/2012 20:47, Amanda Colley wrote:
Ok, here is my problem. If a person has two different people to order
books for, then when using the loop option, How do you add the two seperate
choices together for a final total of books cost?
another='y'
while another=='y' or another=='Y':
choice()
another=input('Do you have another book to order for this student?
'+\
'Enter y for yes: ')
def choice():
book=int(input('Enter the book chioce you want: ' +\
'For Hardback Enter the number 1: ' +\
'Paperback Enter the number 2: ' +\
'Electronic Enter the number 3: '))
num=int(input('Enter how many you need: '))
cost=0
if book==1:
cost=79
elif book==2:
cost=49
elif book==3:
cost=19
b_total=float(cost*num)
print('Your book cost is $ ',format(b_total,'.2f'))
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Create an empty list at the top of your loop. Store your b_total in the
list inside the loop with the append method. When the loop finishes use
the built-in sum function to get the final total.
--
Cheers.
Mark Lawrence.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor