How to make this loop

Godot Version

GODOT 3.2.3 [NOT Godot 4]

I have created this code

func _on_change_1_pressed():
code1 = rng.randi_range(1,9)
#var my_integer = int(my_string)
tt =int($Num1.text)
if tt == code1:
$change_1.queue_free()
if tt > 10:
tt = 10
#var my_string = str(my_number)
$Num1.text = “0”
if tt < 1:
$Num1.text = “9”

now how do I make it loop unitl tt = code1

Use for and break?