I have a dict of items, can I find out if there is a variable named ‘n’
a = {'1': dict(), '2': dict(), '3': dict()}
if 'name_of_element' in a:
pass
How can I check this? There would be no problem if the variables were outside the dictionary, then I would use in globals()
.
New contributor
Sklip is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3