-4

Basically, im trying to make array of arrays in python and i don't know how really. It needs to be in "for" loop and each time it goes trough loop, it needs to add array of some numbers to the array of arrays but of course on index+1

EDIT: this is what i already tried, but it gives me error:

for x in range(5):
        poljeRazina[x][x]=1 
2
  • stackoverflow.com/questions/31250129/… Commented Jan 9, 2019 at 17:39
  • @Bogy what's your expected output. Mention that clearly so I can understand what you actually want because your question is not conveying complete sense. Commented Jan 9, 2019 at 17:50

2 Answers 2

0

In Python, arrays are called Lists. This could be helpful when googling. Also, you can declare them like this (depth-based):

x = [[]]

Then...

for big in range(10):                          #outer loop
    for small in range(10):                    #inner loop
        x[big].append(small*big)               #add new number
        print('%03d' % x[big][small], end=" ") #we print the number padded to 3 digits
    x.append([])                               #add another internal list
    print()                                    #move down to next line

Equals... enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

List comprehension might help

[list(range(i)) for i in range(5)]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.