'using YAML to get input from the user and converting it to dictionary in python

I have to get inputs from the user in YAML form but I can't use any external files, then I have to convert the inputs to dictionaries in which the header would be the key and other elements would be the value stored in a list.

for example, if the input is:

- name: ali
  age: 12
  city: bushehr
  albums:
    - bidad
    - blaze

the answer should be:

{'Ali': (12, 'Bushehr', ['bidad', 'blaze'])}

or for example, if the input is:

- name: bidad
  singer: shajarian
  genre: classic
  tracks: 10
- name: blaze
  singer: ghorbani
  genre: pop
  tracks: 9

the answer should be :

{'bidad': ('shajarian', 'classic', 10), 'blaze': ('ghorbani', 'pop', 9)}

a hand would mean the world to me, thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source