Question: I have a dict with credentials like the following:

```
secret = {"password": "jdksal",
          "user": "fjdklas",
          "schema": "jfdaskl"}

```

I want to create a variable for password, user and schema. However, the secret dict can have other values for each key, so that I would have a list of possibles ways of naming the elements, like the following:

```
pass_words = ['password', 'pass', 'contraseña']

```

Thus, the variable password would be created when any key of the list `pass_words` exists in the dictionary. Only one word from pass\_words would be present in the dict. Same with user, schema etc. So far I have this code:

```
for word in pass_words:
    if word in secret:
        password = secret[word]

user_words = ['user', 'username', 'login', 'name']
for word in user_words:
     if word in secret:
         user = secret[word]

```

It works, but its very verbose. Is there any less verbose way to do it? Thanks

Answer: 
As you have written it, `password` will get the last match if there is more than one overlap between `pass_word` and `secret`. I don't know is that is your intent.

You could use set operations if there is only one overlap:

```
>>> secret.keys() & pass_words
{'password'}
>>> secret.keys() & user_words
{'user'}

```

Then to get the value associated with that key:

```
>>> secret[(secret.keys() & pass_words).pop()]
jdksal
>>> secret[(secret.keys() & user_words).pop()]
fjdklas

```

For older Pythons that don't have dict set views, just apply `set` to each for the same result:

```
>>> set(secret.keys()) & set(user_words)
{'user'}

```

---

With Python 3.6+, you can do:

```
password, user={k:v for k,v in secret.items() if k in pass_words+user_words}.values()

```
I Think This Will Be Better:

```py
pass_words = ['password', 'pass', 'contraseña']

secret = {"password": pass_words,
          "user": "fjdklas",
          "schema": "jfdaskl"}

input_password = input("Enter Your Password: ")
for key,value in secret.items():
    if input_password in value:
        print("Correct Password")

```

You Can Change The Input Method As You Like. The *Key* Variable Will Hold The Key Of The First Item In The Dictionary And The *Value* Variable Will Hold The Value, Which Will Be A List In Your Case, For The First Item In The Dictionary.