range returns a number that is incremented for each iteration, and starts at zero unless otherwise directed.
So range(5) returns 0, 1, 2, 3, 4 (5 values)
It's syntax is: class range(start, stop[, step])
so you can control what it starts with, when it stops, a skip value
example:
In your code that is ' '
the final print adds the new line to complete the process.
So range(5) returns 0, 1, 2, 3, 4 (5 values)
It's syntax is: class range(start, stop[, step])
so you can control what it starts with, when it stops, a skip value
example:
for i in range(1,10,2): print(i, end=', ') print()
Output:1, 3, 5, 7, 9,
the print part uses end = ' '
which tells print not to add a newline, but substitute what's in the quotes instead.In your code that is ' '
the final print adds the new line to complete the process.