How to print values of nested keys in Python

Here address, username and password is my nested keys. How to create a variable for this and print only these keys and not values

Please do not post text in pictures. Copy the Python code and paste it between lines with triple backticks like this:

```
# Your Python code will be here.
```

What I noticed in the picture (although it is hard to work with):

  • We cannot be completely sure what is yaml. You omitted the part of your code assigning this variable.
  • You assign an empty list to output and you do nothing with the list. It stays empty, then you print the empty list at the line 15.
  • Inside the for loop you repeatedly assign a single-element set of None (return value of print()) to date_out. This makes no sense. Maybe you wanted to just call the print()?

To make it easier to help you please show:

  • how your input YAML file structure looks like (with a short example of a usable YAML file)
  • what output you want to get (using the same example YAML)
  • your Python code as a text
  • what you get instead (using the same example)

Put every textual part between lines with triple backticks as I have shown above.

2 Likes