I hope you don't take it personally but you sound pretty young. I recommend if you are as young as I think you are and don't understand my link that you ask your math teach about remainder/modulo as that is the answer to your problem.
You need to use modulus operator.
https://www.computerhope.com/jargon/m/modulo.htm
So if you want a 24 hour day.
0 % 24 = 0
1 % 24 = 1
2 % 24 = 2
.
.
.
.
23$24 = 23
24 % 24 = 0
25 % 24 = 1
26 % 24 = 2
func update_time():
time = (time + 1) % 24
What the above code will do is that anytime you reach 24, time will loop back to 0 without needing any logic.
if you don't what to use modulo, use an if statement
func update_time():
if time == 24:
time = 0
else:
time = time + 1