Python - Printing list vertically Last Updated : 19 Dec, 2024 Comments Improve Suggest changes Like Article Like Report When working with lists in Python sometimes it's necessary to print the elements vertically. This can be useful when we want to display each item on a new line or present data in a structured format. In this article, we will explore various methods to print a list vertically starting with the simplest and most efficient one.Using a LoopThe most simple way to print the elements of a list vertically is by using a for loop. This method iterates over each item and prints it on a new line. The for loop iterates through each item in the list and prints it on a new line.Example: Python a = [1, 2, 3, 4, 5] # Loop to print each element in the list for item in a: print(item) Output1 2 3 4 5 Let's see some more methods to print list vertically in PythonTable of ContentUsing join() with a newline characterUsing List ComprehensionUsing * Operator in Print FunctionUsing join() with a newline characterjoin() method is another efficient way to print a list vertically. By joining the list items into a single string with a newline character (\n) we can print all elements at once making it more compact. Python a = [1, 2, 3, 4, 5] # Use join to print list elements vertically print("\n".join(map(str, a))) Output1 2 3 4 5 Explanation:The join() method combines the list elements into one string with each item separated by a newline.This approach prints the entire list at once making it more compact.The map(str, a) is used to convert each element to a string ensuring that non-string items can be handled.Using List ComprehensionWe can also use list comprehension along with the join() method to print the list vertically. The list comprehension is used to iterate over the list and convert each element to a string. Python a = [1, 2, 3, 4, 5] # Using list comprehension with join to print elements vertically print("\n".join([str(x) for x in a])) Output1 2 3 4 5 Using * Operator in Print Function * operator can be used to unpack the list and print each element on a new line by passing the sep='\n' argument in the print() function.Example: Python a = [1, 2, 3, 4, 5] # Print elements vertically using * operator print(*a, sep='\n') Output1 2 3 4 5 Explanation:The * operator unpacks the list so that each element is passed as a separate argument to the print() function.The sep='\n' argument tells the print() function to separate each argument with a newline. Comment More infoAdvertise with us Next Article Python - Printing list vertically M manjeet_04 Follow Improve Article Tags : Python python-list Python list-programs Practice Tags : pythonpython-list Similar Reads Printing Lists as Tabular Data in Python The goal here is to present lists in a more structured, readable format by printing them as tables. Instead of displaying raw list data, formatting it into tabular form with rows and columns makes it easier to understand and analyze. For example, given a list like [['Name', 'Age'], ['Aditi', 19], [' 2 min read Print lists in Python Printing a list in Python is a common task when we need to visualize the items in the list. There are several methods to achieve this and each is suitable for different situations. In this article we explore these methods.The simplest way of printing a list is directly with the print() function:Pyth 3 min read Multi-Line printing in Python We have already seen the basic use of print function previous article. Now, let's see how to use print function for multi-line printing. This can easily be done using multiline string i.e. three single quotes ''' Geeksforgeeks ''' . Let's see different examples to see the demonstration for the same. 1 min read Python | sep parameter in print() The separator between the arguments to print() function in Python is space by default (softspace feature) , which can be modified and can be made to any character, integer or string as per our choice. The 'sep' parameter is used to achieve the same, it is found only in python 3.x or later. It is als 3 min read How to print spaces in Python3? In this article, we will learn about how to print space or multiple spaces in the Python programming language. Spacing in Python language is quite simple than other programming language. In C languages, to print 10 spaces a loop is used while in python no loop is used to print number of spaces. Foll 2 min read Like