while loop list python

I have the following code which check if the element is in the list if the element has been found then it would add it to alert thereby in a while loop the element would would show up as exists once.

test_list = [ 1, 6, 3, 5, 3, 4 ]
alert = []
while True:
    
    i = 1
    if i in test_list and (i != alert):
        print('exists')
        alert.append(i)

But it is endlessly printing exist. Could you please advise what i need to do so if the element has been found in the list it only prints 1 time as exists

Answer

when you use while True: the code inside it will run forever until you break

so in your code, I think you need to do this:

test_list = [ 1, 6, 3, 5, 3, 4 ]
alert = []
for i in test_list:
    if not i in alert:
        print('exists')
        alert.append(i)

EDIT: if you want to run it forever:

test_list = [ 1, 6, 3, 5, 3, 4 ]
alert = []
while True:
    for i in test_list:
        if not i in alert:
            print('exists')
            alert.append(i)