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 |
I am from non technical Background. In how many days I can learn the python? and What I need to do for that?
What is an elif in python?
What is the dictionary?
How do you get a list of all the keys in a dictionary in python?
What is the purpose of _init_() function in python?
Is javascript harder than python?
What is the cost of python certification?
What do you understand of pep 8?
Does python support interfaces like java does?
Explain me what is python and explain some of its benefits?
What is the mro in python?
What mode is used for both writing and reading in binary format in file.?