psr_21-22 icon indicating copy to clipboard operation
psr_21-22 copied to clipboard

Python If statement

Open josepedropinto-pt opened this issue 3 years ago • 1 comments

Good night,

Is that any way to set and "if condition" true for x amount of time? I've tried lots of options included time.sleep (that didn't work because put lot of lag in the video) and also some timers to calculate the elapsed time but also failed. Do you know if there is another way of doing this?

Thanks

josepedropinto-pt avatar Nov 11 '21 00:11 josepedropinto-pt

Hi @josepedropinto-pt ,

not exactly sure what you mean. If you have a timer like the tic toc we used, just do

start_time = tic()

while True:
   ellapsed_time = tic() - start_time
   if ellapsed_time < x:
       # do stuff

miguelriemoliveira avatar Nov 11 '21 00:11 miguelriemoliveira