2

Does anyone know how to create an array of lists in python?

For example, if I want the final structure to contain data where the 1st dimension is fixed but the 2nd dimension varies:

index 0: [5, 4, 3, 2, 1]

index 1: [6, 5, 4, 3, 2, 1]

index 2: [4, 3, 2, 1]

Cynthia
  • 377
  • 2
  • 4
  • 10

1 Answers1

3

It's just called a list of lists

x=[[5, 4, 3, 2, 1],[6, 5, 4, 3, 2, 1],[4, 3, 2, 1]]
SuperStew
  • 2,857
  • 2
  • 15
  • 27
  • Thanks for the response. How would I initialize it so that the 1st dimension is fixed? For example, if I wanted to initialize it as length 13 so I can access a certain index later. – Cynthia Jul 11 '18 at 20:40
  • Never mind, I found the answer here: https://stackoverflow.com/questions/10712002/create-an-empty-list-in-python-with-certain-size. Thanks for your help! – Cynthia Jul 11 '18 at 20:42