How do I use a list for a pasword system? (PYTHON)

count = 5
while True: 
    UserName = input('Username Arabic Man pls:' )
    PassWord = input('Dont be a nonce:')
    Preset_Username = [{'42'},{'123'},{'preset'}]
    Preset_Password = [{'hi'},{'yes'},{'maybe'}]
    if UserName == Preset_Username and PassWord ==Preset_Password:
        print('Welcome my friend, you are here to do what')
    elif UserName != Preset_Username and PassWord != Preset_Password:
        count -= 1   
        print('False input')
    if count == 0: 

Welcome to the forum. What sort of help are you looking for?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

Please use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks are not single quotes.


  1. You don’t really want to store passwords in plain text. Check links like these for more info.

That said, if you just want a way of checking if input X and input Y match stored values for X and Y, there would be several ways. The way you’re approaching it, the dictionaries in your lists are just keys and not values and I don’t think that will work.

One, you could use two lists:

Preset_Username = [user1,user2,user3]
Preset_Password = [password1,password2,password3]

Then check to see if UserName = Preset_Username[i] and same Password (with same i value).

You could fix your syntax in the dictionaries in the lists, adding a key to each entry:

Preset_Username =[{"key":"value"},{"key":"value"}]

Then basically the same thing.

Or, combine them into a single list of dicts:

Preset_Info = [{"UserName1":"Password1"},{"UserName2":"Password2"}]
  1. But of course however you approach it you’ll need to loop through the list/keys. Your code now would only work if the user entered the value of the whole list as opposed to an entry:

Username =[{'42'},{'123'},{'preset'}]
Is the only way to make UserName == Preset_Username
Same issue with the password.

So, look into using for loops / if statements or other functions to loop through a list (and/or dicts within it) to check for a match. Try using just one input to just one list first, then adapt it for two lists / dicts / list of dicts.