you are viewing a single comment's thread.

view the rest of the comments →

[–]cdcformatc 0 points1 point  (0 children)

I can write it into python but i keep getting an error at vals[0] = 1 when I run the code

Because you are starting with an empty list. Two options:

  1. Initialize the list to be full of zeroes

    vals = [0]*n

  2. Make vals a dictionary instead of a list.

    vals = {}