jeudi 9 juillet 2015

A country that is not Canada

For my code below in python. How do I make it so if the country is not canada then just have it print the total_price with no tax? Right now if I put USA it gives me the right price but it also gives me the price for the other provinces not mentioned.

country = raw_input('What country are you from? ').lower()
if country == 'canada':
    total_price = int(raw_input('What was your total price? '))
    province = raw_input('What province are you from? ').lower()
elif country != 'canada':
    total_price = int(raw_input('What was your total price? '))
if province == 'alberta':
    total_alberta = (total_price * .00005) + total_price
    print 'Your total price is ' + str(total_alberta)
if province == 'ontario' or province == 'new brunswick'\
or province == 'nova scotia':
    total_onn = (total_price * .0013) + total_price
    print 'Your total price is ' + str(total_onn)
if country == 'canada' and province != 'ontario' and province != 'new brunswick' and province != 'nova scotia' and province != 'alberta':
    total_else = ((total_price * .0006) + (total_price * .0005)) \
    + total_price
    print 'Your total price is ' + str(total_else)
else:
    print 'Your total price is ' + str(total_price)

Aucun commentaire:

Enregistrer un commentaire