Suppress automatic display of a list

Summary

For a plot I use the following code line

Steps to reproduce

Code snippet:

[ax.axhline(y=i, xmin=.1, xmax=1, linestyle='--') for i in dates]

Then the lines appear in the plot as they should – but also the list is displayed, which I of course do not want.

Hey, can you share the exact output for the same?

Well, this list ist displayed, as well as the plot. But only the plot should be displayed.

This is a list comprehension which of course returns a list.
Possible one-line solutions:

for i in dates: ax.axhline(y=i, xmin=.1, xmax=1, linestyle='--')

or

_ = [ax.axhline(y=i, xmin=.1, xmax=1, linestyle='--') for i in dates]

Simple enough – thanks. I wasn’t aware I could assign this list to a random variable to not be displayed.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.