[Solved] Why does the while loop never stop looping?


this is b/c the while True does not end unless you use the keyword break wich breaks outside the loop and continues the code.
the while True never ends

the while loop

while (condition):
    #code

never ends until the condition is False, witch would never be true for the True condition.

do your code should be:

game_list = ['0','1','2']

while True:

    position = myfunc()

    replacement(game_list,position)

    if not play_again():
         break
print(game_list)

or you could do:

game_list = ['0','1','2']

while play_again():

    position = myfunc()

    replacement(game_list,position)

print(game_list)

3

solved Why does the while loop never stop looping?