Thursday, July 25, 2019

Python multiple dimension array with range function has negative indexes

I am trying to define a two dimension array with for loops using range function:



>>> takobaba =  [['A' for i in range(0, 6, 1)] for j in range(0, 6, 1)]
>>> takobaba [-1][-1]
'A'


As you can see i get an output for index -1, -1 even i called range function from 0 to 6 with step 1 for both dimensions. Could you please help me to understand the reason and fix this error?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...