Skip to content

Commit

Permalink
Added looping for clean code update
Browse files Browse the repository at this point in the history
Added looping
  • Loading branch information
Ubuntufanboy authored Jun 27, 2023
1 parent 5199776 commit 80a139f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions remote.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
print("Welcome to the Bad Apple remote!")
print("")

Expand All @@ -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():
Expand Down Expand Up @@ -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 >>> ")
Expand Down

0 comments on commit 80a139f

Please sign in to comment.