Python Frequently Asked Questions, Release 3.9.5 2.5.6 How do you make an array in Python? 2.5.7 How do I create a multidimensional list? Chapter 2. Programming FAQ 24 Or, you can use an extension that provides a matrix datatype; NumPy is the best known. This generates a list containing 3 different lists of length two. You can also use a list comprehension: w, h =2,3 A =[[ None ] *w for i in range(h)] A =[ None ] *3 for i in range(3): A[i] =[ None ] *2 The suggested approach is to create a list of the desired length first and then fill in each element with a newly created list: The reason is that replicating a list with$_{*}$doesn’t create copies, it only creates references to the existing objects. The *3 creates a list containing 3 references to the same list of length two. Changes to one row will show in all rows, which is almost certainly not what you want. But when you assign a value, it shows up in multiple places: >>> A [[None, None], [None, None], [None, None]] This looks correct if you print it: >>> A =[[ None ] *2] *3 You probably tried to make a multidimensional array like this: If mutability is desired, you could use lists instead of tuples. Here the analogue of lisp car is lisp_list[0] and the analogue of cdr is lisp_list[1] . Only do this if you’re sure you really need to, because it’s usually a lot slower than using Python lists. lisp_list=("like", ( "this ", ( "example", None ) ) ) To get Lisp-style linked lists, you can emulate cons cells using tuples: The$_{array}$ module also provides methods for creating arrays of fixed types with compact representations, but they are slower to index than lists. Also note that the Numeric extensions and others define array-like structures with various characteristics as well. Lists are equivalent to C or Pascal arrays in their time complexity; the primary difference is that a Python list can contain objects of many different types. ["this ",1,"is","an","array"] Use a list: >>> A[0][0] =5 >>> A [[5, None], [5, None], [5, None]]