Hello i am trying to create a small code that receives password attempts for a number of times (3) , and if the password is wrong , the user can't try again .
can you please tell me why my code is not giving me the expected results i want?
the results it is giving me is a loop that never ends to ask for a try again ; while te results i desire is a loop that ends after 3 trials only . "i would love to keep in the while loop"
thank you very much
my code is
password=''
for i in range(1,3):
if i<3:
while password!='daniel':
password=input("enter the password:")
if password=="daniel":
print('your logged in ')
else:
print('try again ')
else:
print("number of trials done")
`
for i in range(1,3), includingif i<3:is redundant. Similarly,while password!='daniel':makesif password=="daniel":redundant. It might be worth looking into loops, conditions, and thebreakstatement again and rewriting this codewhileloop wouldn't end the very moment its condition becomes false.