7/19 hide


For the following code:

return randint(0, len(board_in) - 1)

I understand the randint section but not quite understanding what the - 1 is all about. What exactly does that do?



randint uses the full supplied range, including the highest value.

x = randint(1, 10) == {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

x will be any of the set above.


Thanks for responding.
I understand what randint is for, but in the code I pasted, there is a - 1 at the end of it. What does the - 1 do, or what does it mean?



Because randint includes the highest value, it needs to be removed since the last index is one less than board length.


Ah ok, that clears things up.

Thanks for the prompt response! I’ve had nothing but really good experiences and great things to say about Codecademy!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.