a = int(input())
b = int(input())
c = int(input())
result = 0
while a < b:
result = a * 2
print(result)
if result > c:
break
a += 3
I used a = 5 b = 12 and c = 16 the solution is 10 16 22 and I can't figure out why where the 16 and 22 come from?
You can always use debugging tools, they are pretty useful and helps you understand more how python interpreter works and catch unexpected outcomes. For example the one in visual studio code or any editor you prefer.
Here is how you get 10, 16, 22
Step 1: Current variable values are
a = 5
b = 12
c = 16
result = 0
Entering while loop as the condition is true
while a < b:
result = a * 2 # 5 * 2
print(result) # 10
if result > c:
break
a += 3 # a = 8
Step 2: Current variable values are
a = 8
b = 12
c = 16
result = 10 # Output 10
Entering while loop as the condition is still true
while a < b:
result = a * 2 # 8 * 2
print(result) # 16
if result > c:
break
a += 3 # a = 11
Step 3: Current variable values are
a = 11
b = 12
c = 16
result = 16 # Output 16
Entering while loop as the condition is still true
while a < b:
result = a * 2 # 11 * 2
print(result) # 22
if result > c:
break # this condition is true as Result = 22 and c = 16
a += 3
Final step which the loop has ended with the following variable values
a = 11
b = 12
c = 16
result = 22 # Output 22
In the final step we are out of the while loop as we broke out in step 3 because the result was greater than c value
I hope you got the answer how you get 10, 16, 22 :)