# How to print values of nested keys in Python

**URL:** <https://discuss.python.org/t/how-to-print-values-of-nested-keys-in-python/19449>\
**Category:** Python Help\
**Created:** [September 26, 2022, 7:16am UTC](https://discuss.python.org/t/how-to-print-values-of-nested-keys-in-python/19449 "2022-09-26T07:16:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![swapnil1518](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/swapnil1518/32/9084_2.png) [@swapnil1518](https://discuss.python.org/u/swapnil1518)\
**Post date:** [September 26, 2022, 7:16am UTC](https://discuss.python.org/t/how-to-print-values-of-nested-keys-in-python/19449/1 "2022-09-26T07:16:39Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/a/a603b00886742bacc7f331e55a30570fb7ddec25.png)

---

<div class="post-metadata">

**Author:** ![vbrozik](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/vbrozik/32/7423_2.png) [@vbrozik](https://discuss.python.org/u/vbrozik)\
**Post date:** [September 26, 2022, 9:05pm UTC](https://discuss.python.org/t/how-to-print-values-of-nested-keys-in-python/19449/2 "2022-09-26T21:05:38Z")

</div>

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

````nohighlight
```
# 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.
