"While" function in GE python?

Can we use the “While” function in GE?

I’ve tried it and it freezes Blender. If you can, can you post here that “while” function, please?

Thank you!

well you can use it, but it will frez blender if it dosent break.
like this


f=open("A FILE","r")
line=f.readline()
while(1):
    if line == "":
        break
    exec(line)
    line=f.readline()
f.close()

so yes you can use the while() function in the Game engine, but be sure to use the break function also. but to have a loop like this


while(1):
    print("Some text..")

dosent work.
this works tho…


while(1):
    print("Some text...")
    break

Thank’s for the tip!