Hey everyone,
I am working on building out some code that allows the user to lookup a password. So far I have been able to get the code to find if the password is currently stored in the list but not print out the password I am looking for. I either can get it to print out the website and passwords all at once, or just the websites that the passwords are stored on.
For example I have a list of websites and passwords for those sites:
passwords = [["msn","12343"],["abc","43521"],["yahoo","asdfg"]]
What I want to be able to do is prompt the user what website they are looking up the password for (accomplished) and after the input print out the website’s password as saved from the list. The errors/roadblocks that I am facing are described above. Could anybody point me in the direction of where I am going wrong? I am specifically struggling to figure out how to call out within my print command the specific list item.
Here are a few of the codes I have tried:
print("Which website do you want to lookup the password for?")
for keyvalue in passwords:
print(keyvalue[0])
passwordToLookup = input()
for passwordToLookup in passwords:
if passwordToLookup in passwords:
print(int(passwords[0,passwordToLookup]))
else:
print("Login does not exist")
break
print("Which website do you want to lookup the password for?")
for keyvalue in passwords:
print(keyvalue[0])
passwordToLookup = input()
for passwordToLookup in passwords:
if passwordToLookup in passwords:
print(str(passwordToLookup))
else:
print("Login does not exist")
break
print("Which website do you want to lookup the password for?")
for keyvalue in passwords:
print(keyvalue[0])
passwordToLookup = input()
for passwordToLookup in passwords:
if passwordToLookup in passwords:
print(passwords[0,passwordToLookup])
else:
print("Login does not exist")
break
print("Which website do you want to lookup the password for?")
for keyvalue in passwords:
print(keyvalue[0])
passwordToLookup = input()
for passwordToLookup in passwords:
if passwordToLookup in passwords:
print(int(passwords[0,passwordToLookup]))
else:
print("Login does not exist")
break
print("Which website do you want to lookup the password for?")
for keyvalue in passwords:
print(keyvalue[0])
passwordToLookup = input()
for passwordToLookup in passwords:
if passwordToLookup in passwords:
print(passwords(int([0,passwordToLookup])))
else:
print("Login does not exist")
break
I can’t really tell which iteration has me the closest or where that iteration may be going bad. As you can probably tell I’ve confused the heck out of myself here haha. Any tips or guidance is greatly appreciated!
Also, this is just one section of a very large application I am working on so there are some defined variables being used here that are worked on prior to this chunk of code… Just FYI.
Thanks,
Dev