0

mod.py:

def addone(number):
    result = number + 1

test.py:

import mod

print mod.addone(2)

The result I get is None, so I am guessing the result variable is missing. What is missing from my code.

And yes, I know this can easily be done without a module, it's just an example.

1
  • 4
    You're missing a return: return number + 1. Commented May 11, 2012 at 16:12

2 Answers 2

2

You're doing the import right, the method in mod.py that is not returning the result. Change to:

def addone(number):
    return number + 1
Sign up to request clarification or add additional context in comments.

Comments

0

'return' is missing in add_one, so you got None

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.