Welcome to the Treehouse Community
Looking to learn something new?
how do you check to see if a dict key exists?
Working on matching items in a list against keys in a dict. Within the for loop of the list, I want to test each item to see if it exists as a key. However, this bit of code hangs up every time.
item == my_dict[item]
How do you check to see if the item exists as a dict key?
I would use:
if item in my_dict: do_something()
Hope that Helps!