Python is repeating
I've started Python today, on a raspberry pi, and I wanted to create
password protected menu. It all works except the options keep appearing
after I enter an option.
This is my code can anyone tell me what is wrong with it please, I have
kept it all here so you guys could see what is wrong. Like I said I get
the first one, shutdown or items but when I enter 1 or 2 it repeats it,
ignoring the if statement.
ans = True
while ans:
print("""
1. Shutdown
2. Items
""")
ans=input("Please enter a number: ")
if ans == "1":
exit()
elif ans == "2":
pa=input("Please Enter Password: ")
if pa == "zombiekiller":
print("""
1. Pi password
2. Return To Menu
""")
else:
print("You Have Entered An Inccorect Password. Terminating
Programm")
import time
time.sleep(1)
exit()
No comments:
Post a Comment