I find it fairly easy to intuit how range works, because mostly I've used it for range(len(something)) (alternatively range(1,len(something))) in which case it grabs every index of something. Like, if len(something) == 10, then the last item in something has an index of 9, so it makes sense that range wouldn't want to try to grab an index 10.
Sometimes this throws me off trying to use actual numbers in range(), though XD
For some reason I often have trouble confusing the syntax of slices and ranges, though. Less as I practice more, but it's not uncommon for my first entry of a statement to have : where it should have ,, or vice versa. Oops.
(Also, stepping by -1 is fun ;) )
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I find it fairly easy to intuit how range works, because mostly I've used it for
range(len(something))
(alternativelyrange(1,len(something))
) in which case it grabs every index ofsomething
. Like, iflen(something) == 10
, then the last item insomething
has an index of 9, so it makes sense that range wouldn't want to try to grab an index 10.Sometimes this throws me off trying to use actual numbers in
range()
, though XDFor some reason I often have trouble confusing the syntax of slices and ranges, though. Less as I practice more, but it's not uncommon for my first entry of a statement to have
:
where it should have,
, or vice versa. Oops.(Also, stepping by -1 is fun ;) )