Reputation: 35
example
{'1':'e1','2':'e2','3':'e3'}
I am wondering if there is a way to isolate the name of the variables into an array of ['1','2','3'], in python.
Upvotes: 0
Views: 29
Reputation: 2069
All you need is list(d)
d = {'1':'e1','2':'e2','3':'e3'}
print(list(d)) # -> ['1', '2', '3']
Upvotes: 1
Reputation: 829
In python: if d = {'1':'e1','2':'e2','3':'e3'}
, then list(d.keys())
will give you ['1', '2', '3']
.
Upvotes: 1