From 80a139fce1216ce371c41c7a8b291d1570c371ef Mon Sep 17 00:00:00 2001 From: Ubuntufanboy <82414370+Ubuntufanboy@users.noreply.github.com> Date: Tue, 27 Jun 2023 05:13:09 +0000 Subject: [PATCH] Added looping for clean code update Added looping --- remote.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/remote.py b/remote.py index 3827fc6..71cb951 100644 --- a/remote.py +++ b/remote.py @@ -1,3 +1,4 @@ +import time print("Welcome to the Bad Apple remote!") print("") @@ -6,7 +7,8 @@ print("2. resume the program") print("3. disable the music") print("4. move the playhead to a certain time") -print("5. exit") +print("5. loop a section of the video") +print("6. exit") def pause(): @@ -38,12 +40,27 @@ def move(): f.write(f"{time}") +def loop(): + start = int(input("Where should the loop start?? ")) + end = int(input("Where should the loop end?? ")) + times = int(input("How many times should it loop? -1 for infinity ")) + if times != -1: + for i in range(times): + with open("MOVE.truconf", 'w') as f: + f.write(f"{start}") + time.sleep(end-start) + if times == -1: + while 1: + with open("MOVE.truconf", 'w') as f: + f.write(f"{start}") + time.sleep(end-start) + def adios(): print("See ya") exit(0) -my_dict = {"1": pause, "2": resume, "3": disable, "4": move, "5": adios} +my_dict = {"1": pause, "2": resume, "3": disable, "4": move, "5": loop, '6': adios} while 1: remote = input("Remote >>> ")