﻿ Python: Display each element vertically of a given list, list of lists - w3resource

# Python: Display each element vertically of a given list, list of lists

## Python List: Exercise - 168 with Solution

Write a Python program to display vertically each element of a given list, list of lists.

Sample Solution:

Python Code:

``````text = ["a", "b", "c", "d","e", "f"]
print("Original list:")
print(text)
print("\nDisplay each element vertically of the said list:")
for i in text:
print(i)
nums = [[1, 2, 5], [4, 5, 8], [7, 3, 6]]
print("Original list:")
print(nums)
print("\nDisplay each element vertically of the said list of lists:")
for a,b,c in zip(*nums):
print(a, b, c)
```
```

Sample Output:

```Original list:
['a', 'b', 'c', 'd', 'e', 'f']

Display each element vertically of the said list:
a
b
c
d
e
f
Original list:
[[1, 2, 5], [4, 5, 8], [7, 3, 6]]

Display each element vertically of the said list of lists:
1 4 7
2 5 3
5 8 6
```

Pictorial Presentation:  Flowchart: ## Visualize Python code execution:

The following tool visualize what the computer is doing step-by-step as it executes the said program:

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿

## Python: Tips of the Day

Decapitalizes the first letter of a string:

Example:

```def tips_decapitalize(s, upper_rest=False):
return s[:1].lower() + (s[1:].upper() if upper_rest else s[1:])
print(tips_decapitalize('PythonTips'))
print(tips_decapitalize('PythonTips', True))
```

Output:

```pythonTips
pYTHONTIPS
```

We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook