You can use a for
loop. range(5)
loops 5 times whatever is inside it. The _
is to indicate that you don’t want to use the value returned by the iterator (In this case range(5)
)
for _ in range(5):
if (value0 == 100):
send_rckey(rc_exit)
else:
send_rckey(rc_program_up)
value0 = checkPicture(15)
For better understanding about for
loop look at the documentation (Note: xrange
is only for Python 2, in Python 3 range
is equivalent to xrange
)
solved How can i shorten this python code [closed]