What does range(5) actually do?

Asked by kemiadewale · 2 weeks ago

1 Answer

30
amorebise · 2 weeks ago Top Answer

range(5) is like a countdown (or count-up) timer. It creates a sequence of numbers: 0, 1, 2, 3, 4.

Notice it starts at 0 and stops before 5. In coding, we almost always start counting from zero. If you use it in a loop, the loop will run exactly 5 times. Think of it as a repetition tool.

Log in to add a comment.