Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren0
whats the problem?
my goal is to enter the password and if its incorrect it gives me another try... and if its true it stopes and says well done. code: Pass = "yahel120" def trypass(): my_input = input ("whats the password?\n").lower() while Pass != trypass(): #while the password is incorrect - it runs this code again and again: trypass() if trypass() == Pass: #if the password is correct it runs this: print ("well done")
4 Antworten
+ 2
You need to return my_input from your trypass() function.
Then you can actually do:
while Pass != trypass():
print("Wrong, try again")
print("Well done.")
+ 1
You are taking input in my_input variable and checking with trypass function
+ 1
my_input == Pass instead of trypass() == Pass
0
Hardik Sharma , how is the code goin to look?