I am new to Python but I am still stuck on how Python call and iterate for loop, showing these with different output and I read the Docs of how it works but got me confused, if I can get help here with out ban I'll appreciate it.strong text
i = 2
j = 1
x = 5
for j in range(x):
print (i)
i+=1
Output:
2, 3 , 4 , 5 , 6
i = 2
j = 1
x = 5
for i in range(x):
print (i)
i+=1
Output:
0, 1, 2, 3 , 4
i = 2
j = 1
x = 5
for i in range(x):
print (i)
x+=1
Output:
0, 1, 2, 3 , 4
i = 2
j = 1
x = 5
for j in range(x):
print (i)
i+=1
Output:
2, 3 , 4 , 5 , 6
Unfortunately, I checked these question 1, 2 and did not help me my question is why every loop give different output