+ 1

Here I try to do a random walk, and calculate the average position (cmcoord), but I get an indexation error.Can anyone spot why?

https://code.sololearn.com/czQSQMoJbe33/?ref=app

24th Jan 2018, 3:20 AM
Fer Lomoc
2 ответов
+ 2
I think the reason for that is because you're trying to call an index number that doesn't exist for r. From what I can see, all r equals is [[x,y]] meaning that it's maximum index is [0][1]. Because i is set to the first index (in the example it would be 0), it is trying to find a number at an index that doesn't exist. Hope this helped!
24th Jan 2018, 3:43 AM
Faisal
Faisal - avatar
+ 1
Thanks Faisal! I think you are right :)
24th Jan 2018, 3:52 AM
Fer Lomoc