I understand the basic concept of the ‘while loop’. But I do not understand why this particular code containing ‘while true’ causes an infinite loop.
condition = 1 while condition < 10: print(condition) condition += 1 while True: print('hello word')
I understand when we start with condition = 1, it is less than 10, so that is is ‘true’. But when we get to condition = 11, doesn’t the statement become false (as 10 is less than 11?). When I run this code, it print hello world forever until the compiler crashes. Why does it keep going? Shouldn’t it stop when the condition = 11? And also, why does the print(condition) no longer show up when I do this?