How to make python repeat specific steps after a step ? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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.

7th Jan 2021, 2:53 AM
Yash Thale
Yash Thale - avatar
10 Respostas
+ 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
7th Jan 2021, 3:59 AM
noteve
noteve - avatar
+ 4
password = "string" while True: inpt = input("Enter password: ") if password == inpt: break print("logging in...")
7th Jan 2021, 3:19 AM
noteve
noteve - avatar
+ 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---
7th Jan 2021, 3:28 AM
noteve
noteve - avatar
+ 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!ā˜ŗ
7th Jan 2021, 3:51 AM
noteve
noteve - avatar
+ 1
怊 Nicko12 怋 Please help now I have added a description of my question.
7th Jan 2021, 3:13 AM
Yash Thale
Yash Thale - avatar
+ 1
怊 Nicko12 怋 I dont understand please explain in a easy way ..
7th Jan 2021, 3:23 AM
Yash Thale
Yash Thale - avatar
+ 1
怊 Nicko12 怋 But how to make it loop ?
7th Jan 2021, 3:44 AM
Yash Thale
Yash Thale - avatar
+ 1
怊 Nicko12 怋 But the app is not letting me to try the codes given for eg. ! What should I do friend ?
7th Jan 2021, 3:54 AM
Yash Thale
Yash Thale - avatar
+ 1
怊 Nicko12 怋 Ok friend.Thankyou for the great help ! šŸ˜‡šŸ˜‡šŸ˜‡
7th Jan 2021, 4:14 AM
Yash Thale
Yash Thale - avatar
0
noteve Hi, thanks for your advice of continuing my learning friend, it's easy like anything for me now...
18th May 2024, 7:35 AM
Yash Thale
Yash Thale - avatar