I have a live process the could be true or false in input. Based on the condition status, if it's true start to write the timecode in a file. I need to write the timecode just the first time the condition is true and add the number of times the condition was true. So, if the statement is true 5 times, I need to write the timecode the first time the condition it's true, ignoring the next true condition, but counting them and write the times the condition was true in the file.
if process:
writeTC(fName,
TC_in, # write only the first time the condition is true
)
writeDuration(fName,
Duration # write duration only at the last true cond.
)
))
Output: 00:00:03:05 7 sec.
Old vague question.
Before answering, please read my question. I now how to use counter, what I'm asking is about the if statement. Thanks. I have a condition inside a loop. I want to print the result once, the first time the condition is true and add the number of times the condition was true.
arr = ['a', 1, 1, 1, 1, 1, 2, 2, 2, 2, 'a', 'a',
3, 3, 'a', 4]
for i in arr:
if type(i) == int:
print('Printed once {i}'.format(i=i))
I would like end up with this result:
There is 5 times the number 1
There is 4 times the number 2
There is 2 times the number 3
There is 1 times the number 4