2

If I have this code:

total_pages= 5
for page in range(1,total_pages+1):
    page +=1
    print(page)

It'll print this:

2
3
4
5
6

It's interesting and I'm curious, because an intern asked me why it's not printed every 2. I would like to understand why the page takes on a new value in the range regardless of whether I increased its value within the for I know WHAT is happening here, but I'd like to understand HOW.

0 Answers0