how to retrieve values from dictionary as list in python?
I can retrieve values by traversing dict but want to know if there is any method.
example:
dt = {1:'A', 2:'B'}
result:
['A','B']
how to retrieve values from dictionary as list in python?
I can retrieve values by traversing dict but want to know if there is any method.
example:
dt = {1:'A', 2:'B'}
result:
['A','B']
Something like this can be very easily achieved in python3 by simply doing:
list(dt.values())
The following works:
val = list(dt.values())
The output is values in dictionary as list: ['A','B']