How to print a list line by line in Python

You can use a for loop to output the elements of a list line by line.

The code sample is shown below:

lst = ["apple", "banana", "cherry"]

for item in lst:
    print(item)

Output results:

apple
banana
cherry

In this example, a for loop iterates through each element in the list lst, assigns each element to the variable item, and then uses the print function to output item line by line.

bannerAds