Indentation is how Python blocks code. Other languages use start and end markers, but in python you indicate which code is inside an if statement by indentation. The code below is a valid if/else.
while True: key.wait_for_press(120) if not key.is_pressed(): os.system("clear") # Linux - OSX print("Welkom bij de morse emulator van maritiem centrum Ameland") else: key_down_time = time.time() #record the time when the key went down tone_obj.play(-1) #the -1 means to loop the sound key.wait_for_release()This code complains about the "else:" because then indentation of the "print" command is an end marker for the "if" statement
while True: key.wait_for_press(120) if not key.is_pressed(): os.system("clear") # Linux - OSX print("Welkom bij de morse emulator van maritiem centrum Ameland") else: key_down_time = time.time() #record the time when the key went down tone_obj.play(-1) #the -1 means to loop the sound key.wait_for_release()The equivalent C code is:
while (1) { wait_for_press(key, 120) if (!is_pressed(key)) { os_system_clear() } print("Welkom bij de morse emulator van maritiem centrum Ameland"); else { key_down_time = time() tone_obj_play(-1) wait_for_release(key) }