1

I am making a game with the same idea as Dance Dance Revolution or more so Guitar Hero. Push the corresponding keys on your keyboard that appear on screen. I have made the function to get the output for the keys but now I need to take the output and place it as the input of another function. I assume that this requires the syntax, 'return' just not sure how to go about doing it. This is my current code regarding.

def randArrow():

    randArrow = ['left', 'right', 'down', 'up']

    for direction in 'randArrow':
        print(random.choice(randArrow))

    return randArrow

2 Answers 2

1

An example of taking the output of a function and putting in another:

def get_value():
   return 5

def print_value(x):
   print(x)

temporary_variable = get_value()

print_value(temporary_variable)

or better:

def get_value():
   return 5

def print_value(x):
   print(x)

print_value(get_value())
Sign up to request clarification or add additional context in comments.

Comments

0

If you had a function printFirstArrow that took a list as an argument, you could pass the output in as printFirstArrow( randArrow() ). ex:

def printFirstArrow( arrows ):
    print arrows[0]

printFirstArrow( randArrow() ) // 'left'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.