Arduino does not respond to Python codes

Hello world.

So, this is my situation. TX and External LED responds to "Examples" -> "Blink" from Arduino IDE. I tried to play around with delay and it worked fine. But when I try to run similar code with Python it does not respond but stucks in the last code run by Arduino IDE. The code runs clean yet Arduino does not respond to commands; the LEDs keeps on blinking at set rate. Where might be the problem?

#Python Code for Arduino LED Control
import serial
import os
import time


arduino = serial.Serial("COM3", 9600)

def onOffFunction():
    command = input("Type in something (on/off/bye): ");
    if command == "on":
         print ("The LED is ON")
         time.sleep(1)
         arduino.write(b'H')
         onOffFunction()
    elif command == "off":
        print ("The LED is OFF")
        time.sleep(1)
        arduino.write(b'L')
        onOffFunction()
    elif command == "bye":
        print ("Bye Bye!")
        time.sleep(1)
        arduino.close()
    else:
        print ("Sorry.. Try typing something else.")
        onOffFunction()

time.sleep(2)

onOffFunction()

Here is how I connected everything.

This simple Python - Arduino demo should help get you started.

See also Serial Input Basics - simple reliable ways to receive data.

...R