Print a list


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.

Print list 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)

Output

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

Print list, element by element, to console output

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)

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.