How to print a list in Python?

Print a List

To print a list in Python, we can pass the list as argument to print() function. The print() function converts the list into a string, and prints it to console output.

If we need to print elements of the list one by one, we can use a loop statement like while or for loop, iterate over the elements of the list, and print them to console output.

In the following program, we take a list of fruit names, and print this list using print statement.

Python Program

# Initialise a list
myList = ['apple', 'banana', 'cherry']

# Print list to console output
print(myList)
Run Code Copy

Output

['apple', 'banana', 'cherry']

In the following program, we take a list of fruit names, and print this list, element by element, using a for loop and print statement.

Python Program

# Initialise a list
myList = ['apple', 'banana', 'cherry']

# Print list to console output element by element
for element in myList :
	print(element)
Run Code Copy

Output

apple
banana
cherry

Summary

In this tutorial of Python Examples, we learned how to print a given list to console output, using print() function.

Related Tutorials

Code copied to clipboard successfully 👍