mardi 28 avril 2015

Why isn't my elif statment working? [duplicate]

This question already has an answer here:

Im new to python and im currently doing a practise sac for IT and im trying to get the program to read the first digit of the postcode and then set the number to the billing variable. When i run it, it just sets it as the first if statement even though the first number is not a 0 or a 6. Please help me out!!!![enter image description here][1]

#commision = 1.125 For later on
#bid = 100 part of prac sac
total_cost = str(0)
billing = 0

for i in range(100000):
    postcode = input("What is your postcode?: \n")
    if len(postcode) == 4:
        break
    else:
        print("Postcode invalid. Please retype postcode.")
        continue

print(postcode)
print(postcode[0])

# This is where im having trouble
if (postcode[0]) == str(0) or str(0):
    billing = 25

elif (postcode[0]) == str(1) or str(2) or str(5):
    billing = 15

elif (postcode[0]) == str(3):
    billing = 12

else:
    billing = 20

print(billing)

Aucun commentaire:

Enregistrer un commentaire