How to print a list in Python.

In Python, you can print a list using the print() function. You can directly pass the list as an argument to the print() function as shown below:

my_list = [1, 2, 3, 4, 5]

print(my_list)

Output:

[1, 2, 3, 4, 5]

You can also loop through each element of the list and print them out one by one, as shown below:

my_list = [1, 2, 3, 4, 5]

for element in my_list:

    print(element)

Output:

1

2

3

4

5

bannerAds