0

¿how I can stop after an "else"?

how can I stop the code or have it return to the same action after an "else"? since the objective of what I did is a page from a bank but it is assumed that when the password was wrong, it stopped or restarted any help please P.D: I recommend using a separate compiler to see the error as a spyder and not speak English well https://code.sololearn.com/cP8MT8qfZBB5/?ref=app

18th Apr 2019, 4:58 AM
José Antonio Matuz Argueta
José Antonio Matuz Argueta - avatar
3 Antworten
+ 7
You can do if password != "79075": # access denied else: # opening bank # welcome etc By grouping it this way, the remainder of the program will not be performed should the password be wrong. If you want to give the user a few attempts to get the password correct, then you'll need a loop for that.
18th Apr 2019, 5:19 AM
Hatsy Rei
Hatsy Rei - avatar
+ 8
Another way: login = password == "79075" if login: print ("opening the bank") else: print ("Access Denied") if login: print ("Welcome to your Status\nWhat do you want to see?") (...) Note that any solution like this would be highly insecure in real life 😶 https://code.sololearn.com/czJn3Pi3kUgm/?ref=app
18th Apr 2019, 5:59 AM
Anna
Anna - avatar
+ 2
https://code.sololearn.com/cq0r8bsw79X9/?ref=app this code doesn't work in St playground but it works fine on my local installation. this is just to show you how to restart from a point if your requirements are not met using loop...
18th Apr 2019, 6:28 AM
Akpé Aurelle Emmanuel Moïse Zinsou
Akpé Aurelle Emmanuel Moïse Zinsou - avatar