+ 3
how to find value in dictionary if there is user input??
dic={a:'123',b:'567'} sample dic user=input ('enter:') how to retrieve 123 if user enter a for example
4 odpowiedzi
+ 3
Thank you Jan and Markus. I wrote print(dic.get(user)), it didn't work out.
+ 2
Actually, i m planing to use loop and dic is a lot of strings.
+ 1
print(dic['a'])
Also, you might want to make the dictionary keys into strings,
0
you shouldnt use a loop to do simple stuff ex. if you only need single values, Jans first example is the best way to go.