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.
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)
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
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 Python skills with w3resource's quiz
Python: Tips of the Day
When we speak of division we normally mean (/) float division operator, this will give a precise result in float format with decimals.
For a rounded integer result there is (//) floor division operator in Python. Floor division will only give integer results that are round numbers.
print(1000 // 300) print(1000 / 300)
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework