result_names = 'elena' dict={"glenn":1,"elena":2} def person(names): pins =dict.get(names) return pins pins = person(result_names) print(pins)you need to assign the value returned from the function to a name (unless you use it directly and not plan to use it again)
by the way, don't use
dict
as variable name - it's a build in function.Also, you use it inside the function (as global name). It's better either have it inside the function or pass it as argument like you do with
names
(in which case there is the question do you need the function at all)name = 'elena' def get_pin(name): """ Given a name, return pin """ users = {"glenn":1, "elena":2} pin = users.get(name) return pin # you can replace this line and the previous with return users.get(name) pin = get_pin(name) print(pin)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs