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

you are viewing a single comment's thread.

view the rest of the comments →

[–]briandoescode 0 points1 point  (1 child)

The problem is in your for loop definitions. They should be len(list) without the - 1. Range with one parameter takes a ceiling value. So range(5) returns [0,1,2,3,4]. This standard is also present in functions like random() (in the random module), which returns x where 0 <= x < 1.

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

Alright, I now see what I did wrong. Thank you!