vendredi 20 février 2015

Multiple IF and ELIF conditionals [Python]


name="admin"
passw="aaa"

itemone="01"
itemtwo="02"

a=input("Enter your username:")
b=input("Enter your password:")

if(a==name)and(b==passw):
print("Welcome.")
c=int(input("Enter Item Code:"))

if(c==itemone):
print("Name: ID")
elif(c==itemtwo):
print("Name: Mirror")
else:
print("Item not found. Try again.")

else:
print("Username/Password is incorrect.")
exit()


when "01" or "02" is entered, the program ignores all the other codes and directs to "item not found. try again."


Aucun commentaire:

Enregistrer un commentaire