0

I am trying to get 2 values from my getValues function and return it as a parameter to my askQuestion function

I get an error:

TypeError: askQuestion() missing 1 required positional argument: 'curA'

#getting a question and index for the answer
def getValues():
    curQ = r.choice(qs)
    index = qs.index(curQ)
    curA = ans[index]
    #returning question and answer to next function
    return curQ, curA
    
#prompting the user with question for answer
def askQuestion(curQ, curA):
    userA = input(question + ": ")
    userA.upper()
    userA.replace(" ", "")
    #using variable because it wont let me carry it over
    answer.append('')
    #returning answer and user's answer
    return curA, userA

askQuestion(getValues())
2
  • getValues is returning a list containing (curQ, curA), i.e. 1 variable. You can change your askQuestion() function to take an array input Commented Nov 2, 2021 at 4:31
  • @JacksonB It's a tuple, not list or array. Commented Nov 2, 2021 at 4:41

1 Answer 1

2

Use the spread operator to separate the return tuple into separate arguments.

askQuestion(*getValues())
Sign up to request clarification or add additional context in comments.

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.