(Jan-22-2021, 02:08 PM)buran Wrote: input
will return str
, so you need to compare choice
with '2'
or convert the user input to int
and then you can compare with 2
.
Then to end the loop choice
must become 'exit'
also, I must comment on excessive use of brackets - no need of brackets in cases like ("enter")
So your solution did work but when I input an incorrect value but after that, I input the correct value '2' it still says error.
#getpass will hide what the person is typing during the password
import getpass
def new_entry():
#input the username and password and the website
Website = input("Enter the website: ")
Username = getpass.getuser()
Password = getpass.getpass()
#Menu to choose if you want to add, see or remove
print(" *************************")
print(" /$$ /$$ /$$$$$$ /$$$$$$$ \n| $$ | $$|_ $$_/| $$__ $$\n| $$ | $$ | $$ | $$ \ $$\n| $$$$$$$$ | $$ | $$ | $$\n| $$__ $$ | $$ | $$ | $$\n| $$ | $$ | $$ | $$ | $$\n| $$ | $$ /$$$$$$| $$$$$$$/\n|__/ |__/|______/|_______/ ")
print("**************************")
print ("1. See the list\n2. Add new entry")
choice = int(input(""))
c = "enter"
while c != ("exit"):
if (choice) == (2):
new_entry()
c = ("enter")
#if you select option 2 it will call the new_entry code
else:
choice = input("ERROR:\nInvalid input: Please type agian\n")
#Store this somewhere
Feel free to try it out and thanks