Categories
Python Answers

How to print list items with Python?

Spread the love

Sometimes, we want to print list items with Python.

In this article, we’ll look at how to print list items with Python.

How to print list items with Python?

To print list items with Python, we can call print with the sep argument set to separator string to separate each item being printed.

For instance, we write

print(*my_list, sep='\n')

to print all the items in my_list separated by a new line character.

We use * to unpack the items in my_list list as arguments.

Conclusion

To print list items with Python, we can call print with the sep argument set to separator string to separate each item being printed.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *