I've created a python dictionary
user = input('enter a letter: ')
d = {'a': '1', 'b': '2', 'c':'3'}
print(d.get(d))
I run that and enterned
a
But I always get an error like this
er a letter: a
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 3, in <module>
TypeError: unhashable type: 'dict'
[Program finished]
Help me to slove!
You have to use the variable with user's input:
user = input('enter a letter: ')
d = {'a': '1', 'b': '2', 'c':'3'}
print(d.get(user))