Post History
Replace range() if $n < 4$ If you're using a for loop, you're probably using range() for the list count. You can actually replace it if the number inside range() is less than 4. Why? Examine th...
Answer
#1: Initial revision
# Replace `range()` if $n < 4$ If you're using a `for` loop, you're probably using `range()` for the list count. You can actually replace it if the number inside `range()` is less than 4. Why? Examine the lengths on the code: ``` 0,1 0,1,2 0,1,2,3 0,1,2,3,4 range(n) ``` `range()` takes more bytes than the list from 0 to 3. <!-- language-all: lang-python --> for i in 0,1,2,3:print(i) [Try it online!][TIO-kte0zci7] [TIO-kte0zci7]: https://tio.run/##K6gsycjPM/7/Py2/SCFTITNPwUDHUMdIx9iqoCgzr0QjU/P/fwA "Python 3 – Try It Online"