```
while True:
a+=1
sum+=a
if sum>s:
break
```

This syntax and

```
while sum<s:
a+=1
sum+=a
if sum>s:
break
```

I wonder why this phrase is different and doesn't work

python

2022-09-20 10:48

Both are running...?

```
import random
s = random.randomint (0,9987) # I picked randomly just in case there is a problem with the value of s
sum = 0
a = 0
while True:
a += 1
sum += a
if sum > s:
break
print(sum)
sum = 0
a = 0
while sum < s:
a += 1
sum += a
# If sum > s: # <--- These two lines are actually unnecessary.
# This is the case when you think about the principle of operation of break # <--- while.
print(sum)
```

2022-09-20 10:48

© 2022 pinfo. All rights reserved.