[Tutor] using the loop function while another
Amanda Colley
acolle00 at g.uafortsmith.edu
Tue Oct 9 21:47:35 CEST 2012
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'))
--
Amanda Colley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121009/e5a642c3/attachment.html>
More information about the Tutor
mailing list