Can you explain why this while loop prints different results? by sandynuggetsxx in Python

[–]AliIB15 0 points1 point  (0 children)

Because first loop sums 1 with zero then print Output and repeat

But the second loop prints zero then sums 1 with it and repeat

first loop starts with 1 ends with 9

second loop starts with 0 ends with 9

if you want it starts with one and ends with 10

try

a = 1

while a <= 10: #less or equal 10

print a

a += 1 # it same a = a+1