I'm trying to pass two arguments to the switcher function, then use one of those arguments to define the switch case, and one of them to be passed to the case function. The portion of the code I provided has the function for one of the cases, the rest are similarly formatted.
I'm not sure if this is the right approach to creating this function, or why I am getting this error.
right = 1
def Default():
print('Something went wrong :(')
def Right(duration):
pyautogui.moveTo(1123,899) #Right Arrow Button
pyautogui.mouseDown()
time.sleep(duration)
pyautogui.mouseUp()
time.sleep(0.03)
def Move(direction,duration):
switcher = {
1: Right(duration) ,
2: Left ,
3: Down ,
4: DiagonalUp
}
return switcher.get(direction, Default)()
x = 2.5
Move(right,x)
The error I get is: line 48, in Move return switcher.get(direction, Default)() TypeError: 'NoneType' object is not callable
I do not get this error when I don't include the duration variable at all in the code.