# Python | Printing list vertically

• Last Updated : 22 Jan, 2019

Printing the list has been dealt many times. But sometimes we need a different format to get the output of list. This also has application in getting a transpose of matrix. Printing list vertically also has application in web development. Lets discuss certain ways in which this task can be achieved.

Method #1 : Using Naive Method
The naive method can be used to print the list vertically vis. using the loops and printing each index element of each list successively will help us achieve this task.

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

 `# Python3 code to demonstrate ``# Vertical list print ``# using naive method `` ` `# initializing list  ``test_list ``=` `[[``1``, ``4``, ``5``], [``4``, ``6``, ``8``], [``8``, ``3``, ``10``]]`` ` `# printing original list``print` `(``"The original list is : "` `+` `str``(test_list))`` ` `# using naive method  ``# to print list vertically``for` `i ``in` `range``(``len``(test_list)):``    ``for` `x ``in` `test_list:``        ``print``(x[i], end ``=``' '``)``    ``print``()`

Output :

```The original list is : [[1, 4, 5], [4, 6, 8], [8, 3, 10]]
1 4 8
4 6 3
5 8 10
```

Method #2 : Using `zip()`
Using zip function, we map the elements at respective index to one other and after that print each of them. This performs the task of vertical printing.

 `# Python3 code to demonstrate ``# Vertical list print ``# using zip()`` ` `# initializing list  ``test_list ``=` `[[``1``, ``4``, ``5``], [``4``, ``6``, ``8``], [``8``, ``3``, ``10``]]`` ` `# printing original list``print` `(``"The original list is : "` `+` `str``(test_list))`` ` `# using zip() ``# to print list vertically``for` `x, y, z ``in` `zip``(``*``test_list):``    ``print``(x, y, z)`

Output :

```The original list is : [[1, 4, 5], [4, 6, 8], [8, 3, 10]]
1 4 8
4 6 3
5 8 10
```

My Personal Notes arrow_drop_up