0

I need to run calc(a,b) 10 times but after the first iteration, I want to pass it's output which is a tuple as a parameter.

def test(a,b, count = 1):
    if count == 10:
        return
    cr = calc(a,b)
    return test(cr[0],cr[1], count+1)

print(test(10,4)) returns None

2
  • 2
    In the base case, return means return None, and this returned value is propagated to the original caller. Commented Feb 16, 2018 at 5:24
  • What do you want test(10,4) to return? And please give the definition of calc also, so that your question becomes Minimal, Complete, and Verifiable - stackoverflow.com/help/mcve Commented Feb 16, 2018 at 5:37

1 Answer 1

1

It returns none because you are not returning anything add, return cr, also ensure you define cr before you attempt to return it

def test(a,b, count = 1):
    cr = calc(a,b)
    if count == 10:
        return cr
    return test(cr[0],cr[1], count+1)
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.