Explain how to create a multidimensional list.
Answer / chaitanya
There are two ways in which Multidimensional list can be created:
By direct initializing the list as shown below to create multidimlist below
>>>multidimlist = [ [227, 122, 223],[222, 321, 192],[21, 122, 444]]
>>>print multidimlist[0]
>>>print multidimlist[1][2]
__________________________
Output
[227, 122, 223]
192
The second approach is to create a list of the desired length first and then fill in each element with a newly created lists demonstrated below :
>>>list=[0]*3
>>>for i in range(3):
>>> list[i]=[0]*2
>>>for i in range (3):
>>> for j in range(2):
>>> list[i][j] = i+j
>>>print list
__________________________
Output
[[0, 1], [1, 2], [2, 3]]
| Is This Answer Correct ? | 0 Yes | 0 No |
Does python have oops concepts?
Which method removes and returns last object of a list?
How are arguments passed - by reference or by value?
What are all important modules in python reuired for a data science ?
What are the two ways to use python interpreter?
What are the rules for legal python names?
Why do we say “a b c = 1000 2000 3000” is an invalid statement in python?
How do you sort a list in python?
What is “call by reference” in python?
Explain assert in action?
What are all the operating system that python can run on?
What is the result of pow(x,y)?