top of page

Python Tutorial

Public·1 member

How can I get list of values from dict?

# d is dictionary of character count


d = {'a': 3, 'b': 5, 'c': 8}


Get dictionary values in python 2:

d.values()

In Python 3:


>>> d = {'a': 3, 'b': 5, 'c': 8}
>>> d.values()
dict_values([3, 5, 8])
>>> list(d.values())
[3, 5, 8]
8 Views
bottom of page