import getpass
p = getpass.getpass(prompt='What is the code you were given?? ')
if p.lower() == 'breakout':
print('Welcome..!!!')
else:
print('The answer entered by you is incorrect..!!!')
I tried a few things, all of them gave errors.
CodePudding user response:
Reset?. You mean you need to ask again if password is wrong?..if so Use while True
until password is Correct
import getpass
while 1:
p = getpass.getpass(prompt='What is the code you were given?? ')
if p.lower() == 'breakout':
print('Welcome..!!!')
break
else:
print('The answer entered by you is incorrect..!!!')
output #
What is the code you were given?? ok
The answer entered by you is incorrect..!!!
What is the code you were given?? breakout
Welcome..!!!
CodePudding user response:
You can do something like this:
import getpass
p = ""
while p.lower() != "breakout":
p = getpass.getpass(prompt="What is the code you were given?? ")
else:
print("Welcome..!!!")