Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
calpaterson
on Oct 23, 2013
|
parent
|
context
|
favorite
| on:
Why Python uses 0-based indexing. It's because of ...
I frequently have off-by-ones with range. len(range(1, 100)) == 99
aidos
on Oct 24, 2013
|
next
[–]
Simplify it:
len(range(100)) == 100
Though - I've written a lot of python code and I never use range. The beauty of python is that all collections are iterable so you seldom need to specify ranges.
anonymoushn
on Oct 23, 2013
|
prev
[–]
Yes, it's 100-1. len(range(25,100)) == 75 == 100-25
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: