I have a function with 2 arguments. I would like to display the output using varying inputs of the arguments that can be found in two lists using a loop. I have executed the code successfully with one list (ages) but not with (ages) and (game).
# the below code works for 1 list assignment to the a argument
for a in ages:
print(age_price_event(a, 2))
# when I try this to assign the other argument I get an error.
for a in ages b in game:
print(age_price_event(a, b))
File "", line 1 for a in ages b in game: ^ SyntaxError: invalid syntax
# Here is the function that I wrote
# Function that has two elements
# a is the age of person
# b is the game
def age_price_event(a, b):
str(b)
if b == 1: # looks to see if it is for 1
if a < 4: # if so execute code below
return (0)
elif a < 18:
return (10)
else:
return(15) #Stop here
if b==2: # looks to see if it is for 2
if a < 4: # if so execute code below
return (5)
elif a < 18:
return (55)
else:
return(66) #Stop Here
else: # if not game is not toady
return ("That Game is not Today")
# here are the list to be assign to the arguments
ages = [11, 22, 14, 25]
game = [ 1, 1, 2, 3]
# the below code works for 1 list assignment to the a argument
for a in ages:
print(age_price_event(a, 2))
# when I try this to assign the other argument I get an error.
for a in ages b in game:
print(age_price_event(a, b))
the below code works for 1 list assignment to the a argument
55
66
55
66
when I try this to assign the other argument I get an error.
File "<ipython-input-158-2d5fb2f7d37f>", line 1
for a in ages b in game:
^
SyntaxError: invalid syntax