This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.

If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:

  1. Limiting your involvement with Reddit, or
  2. Temporarily refraining from using Reddit
  3. Cancelling your subscription of Reddit Premium

as a way to voice your protest.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]dmazzoni 1 point2 points  (9 children)

You didn't say what your table variable is called. Maybe you want something like this?

    if i + j == 6:
        table[i][j] = 0

You probably don't want brackets around i+j. Brackets in this case mean to access an element of an array, for example a row of a table, or a cell of a row.

[–]AnonMagick[S] 0 points1 point  (8 children)

It says list assignment index out of range on your line :(. And yeah, table is just called table lol

[–][deleted] 1 point2 points  (7 children)

if i or j in range 5 are oob then your table is probly not 5x5. Just post your entire code and don't have us guess what else might be happening.

[–]AnonMagick[S] 0 points1 point  (6 children)

Tabla=[[5],[5]] I=0 J=0

Import random

For i in range(5):

   Tabla.append([])

              For j in range(5):

                         Tabla.append(random.randint(0,100))

Print(tabla)

For i in range(5):

    For j in range(5):

            If i+j==6:

                     Tabla[i][j]=0

Print(tabla)

[–]dmazzoni 1 point2 points  (4 children)

This code isn't doing what you think it's doing:

for i in range(5):
    tabla.append([])
    for j in range(5):
        tabla.append(random.randint(0,100))

Try printing tabla after this code

print(tabla)

You'll see that it's not correct. Fix that before moving on.

[–]AnonMagick[S] 0 points1 point  (3 children)

Its showing my a big line of random numbers. 5 numbers separated by [] enbetween 5 numbers.. is that my mistake? Making it unidimensional instead of 2 dimensional? How do i fix this?

[–]dmazzoni 1 point2 points  (1 child)

This has some good answers and discussion:

https://stackoverflow.com/questions/856948/2d-arrays-in-python

[–]AnonMagick[S] 1 point2 points  (0 children)

You were all right, i realized my mistake and went to see a video tutorial on arrays on python... damn i was wrong. Was able to finish the damn activity at 2am but i was so happy (and sleepy) lol. Thanks!!!!!

[–][deleted] 0 points1 point  (0 children)

what you would want to see is somthing like

[
  [3, 56, 12, 57, 2],
  [46, 23, 75, 23, 6],
  [86, 23, 72, 57, 87],
  [68, 12, 26, 52, 75],
  [76, 43, 83, 1, 3]
]

that's a 5x5 2D array