Python: for i in range (1, 10), print (i). Why does it not print the number 10?
I talked with my data science tutor for almost 20 minutes and he couldn't give me an answer beyond: "It just doesn't give you the last value. It's just something you remember."
Posted Oct 29, 2021, 10:17 PM UTC
First arg is including. Srcond one is excluding
So it's range from (and including) 1 up to (but not including) 10?
Correct
Because python...
Which language doesn't do that?
Programmers are used to index 0, and calling
range(0, 10)is equivalent of writing a common for-loopfor (int i = 0; i < 10; i++).