How dump do I have to be? Why does this keeps on printing?

I’m using Godot4.3. What is wrong with this code? why does it keeps printing?

var i = 0
var som = true

while som:
	i += 1
	print(i)
	if i > 20:
		som = false
		break

Try it:

var i = 0
while i <= 20:
  i += 1
  print(i)

if you need som var:

var i = 0
var som = true
while i <= 20:
  i += 1
  print(i)
  if i > 20:
    som = false

The code you post outputs 1 to 21 and then exits the loop.

Thanks! The only question I have is why it outputs 1 to 20 and than it repeats 1 to 20 to infinity

Also thanks for the replies. This forum is amazing!

Did you place this code in a _process or _physics_process function? Either of those will run every frame.

after extends ... place it and run, print 1 to 20:

func _ready():
	var i = 1
	while i <= 20:
		print(i)
		i += 1

Dang. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Thanks man