+ 1
Python Range
Hello everyone. If I execute the code "print(range(20))" the list counts up to 19 . Why number "20" is not included?
3 Answers
+ 2
Well, the range() method starts with number 0, so if you count it from 0 to 19 is equal to 20. but if you want it to count from 1 to 20, just try using list(range(1,21))
+ 2
What always messes me up is going back and forth between range() and random.randint() in a program. The arguments for randint follow the rules in your post. Always end up having to debug.
0
Thanks a lot Giam Paolo.