+ 1
How to make python repeat specific steps after a step ?
I want make a program in which will save and verify a password but if the confirmation doesn't match, I want to get the first two steps repeated untill I get the password confirmed.
10 odpowiedzi
+ 2
Yeah, because that code and the repeated steps you are talking about needs an interactive multiple input, Sololearn code playground does not support multiple inputs. So use different IDE or if you're using phone, download PyDroid3
+ 4
password = "string"
while True:
inpt = input("Enter password: ")
if password == inpt:
break
print("logging in...")
+ 2
So here for example, the password is "string", now we have to get the input of the user UNTIL it matches the original password.
"while True:" means we get the input repeatedly and when the input password now matches the original password which is "string" the "if password == inpt" will become True and so the loop will break.
For example:
password = "string"
INPUTS
---Loop 1---
>> string123 # this is not the password
---Loop 2---
>> strabcd # this is not the password
---Loop 3---
>> string # this is the password
---LOOP ENDS---
+ 2
Yash Thale Just continue your course and you will learn it in your following modules and lessons. I suggest to always check the comment sections in lessons, people give extra explanations and examples there.
Keep Learning!☺
+ 1
《 Nicko12 》 Please help now I have added a description of my question.
+ 1
《 Nicko12 》 I dont understand please explain in a easy way ..
+ 1
《 Nicko12 》 But how to make it loop ?
+ 1
《 Nicko12 》 But the app is not letting me to try the codes given for eg. ! What should I do friend ?
+ 1
《 Nicko12 》 Ok friend.Thankyou for the great help ! 😇😇😇
0
noteve Hi, thanks for your advice of continuing my learning friend, it's easy like anything for me now...