Can anybody solve it pls?! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anybody solve it pls?!

What I want is to print hi if hi is present in the list. And the list is present in a dict name greeting. But it's giving error! https://code.sololearn.com/cO2O3z3ZJYaO/?ref=app

15th Sep 2022, 8:10 AM
Kaushik
Kaushik - avatar
2 Answers
+ 6
greetings['user_question'] Dictionary values are accessed using [] brackets around the keys, not (). Also there is a spelling error in your key
15th Sep 2022, 8:34 AM
Lisa
Lisa - avatar
+ 2
Kaushik , we can access dictionaries values also by using .get(...) method like: if a in greetings.get('user_question'):
15th Sep 2022, 10:42 AM
Lothar
Lothar - avatar