Getting All Values ​​from a Dictionary in Python

In Python, you can also get all the values ​​from a dictionary. To do this, use the values method. Nothing is passed to its parameter. The method returns a special object dict_values.

Let us have the following dictionary:

pythondct = {
  'a': 1,
  'b': 2,
  'c': 3
}

Let's derive all the values ​​from it:

pythonres = dct.values()
print(res) # dict_values([1, 2, 3])

To make it easier to work with the dict_values object, you can convert it to a list. This is done using the list function:

pythonres = list(dct.values())
print(res) # [1, 2, 3]
Задание 1

Given a dictionary:

pythondct = {
  'x': 1,
  'y': 2,
  'z': 3
}

Get all its values.

Задание 2

Given a dictionary:

pythondct = {
  1: 'x',
  2: 'y',
  3: 'z',
  4: 'w'
}

Get all its values.

Задание 3

Given a dictionary:

pythondct = {
  'x': 1,
  'y': 2,
  'z': 3
}

Get a list of meanings for this dictionary.

Задание 4

The following dictionaries are given:

pythondct1 = {
  'a': 1,
  'b': 2,
  'c': 3
}

dct2 = {
  1: 'a',
  2: 'b',
  3: 'c'
}

Get their values ​​in the following form:

python[1, 2, 3, 'a', 'b', 'c']