I am trying to iterate over the list items in python based on some condition if met. I have 5 strings in the list and I want to consider the first element and check my condition. if only the condition meets, then I want to go to the second element and so on.
mylist = ["1","2","34","44","55",]
for m in mylist:
pyperclip.copy(m)
print(m) # I want to print it every 30 seconds after the condition meets!
roll = "34"
if roll == m:
print(roll) # Now wait for next m from the list!
Explanation:
Let's say, I took 1 from the list, then i copied it and printed it. now before i print another m from the list, I have to wait for the condition. if roll
is equal to m
then print roll and wait until the next m
has been printed (i.e. until those 30 seconds). I want to do it infinitely, Do I need while loop?
Please fell free to ask for more explanation.
Thanks!