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]

0

1 Answer 1

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]]
Sign up to request clarification or add additional context in comments.

2 Comments

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.
Never mind, I found the answer here: stackoverflow.com/questions/10712002/…. Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.