I'm not sure why I keep getting an error for the "print func()" part, saying it's an invalid syntax. I'm trying to have the switcher go to a definition for each value it receives. The code runs the loop properly it's just the switcher part I'm having trouble with.
import numpy as np
i = 0
# get the order the balloons need to be popped in
# just put the number
yellow = input ("When does yellow get popped ")
red = input ("When does red get popped ")
blue = input ("When does blue get popped ")
green = input("When does green get popped ")
print("")
# put them in an array for the switcher function
order = [yellow, red, blue, green]
# a while loop that will go through the switcher until
# all ballons have been popped
while i < 4:
def yellow_turn():
return "pop yellow next"
def red_turn():
return "pop red next"
def blue_turn():
return "pop blue next"
def green_turn():
return "pop green next"
next_ball = order[i]
print(next_ball)
def ballon_order(next_ball):
switcher = {
0: yellow_turn,
1: red_turn,
2: blue_turn,
3: green_turn,
}
func = switcher.get(next_ball, lambda: "Invalid input")
print func()
i += 1