Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Explain how to create a multidimensional list.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is string in python?

911


Is c# better than python?

831


What is list comprehension? Give an example.

1128


Difference between __str__ and __repr__?

829


What is static in python?

881


What is the purpose of the pythonpath environment variable?

922


How does raw_input work in python 3?

837


Why we are using a python dictionary?

944


Do you know what the difference between lists and tuples is? Can you give

938


Why python is faster than java?

878


How can you find length of a tuple in python?

788


What is a class method?

822


What kinds of patterns could I enforce on the code to make it easier to translate to another programming language?

841


Is python faster than matlab?

865


How do I apply a method to a sequence of objects?

930