Assigning the answer of a function to a variable?(in python 2.4.4)

Question:

def BSformula(num1):
    """my formula"""
    (num1 - 2.0) * (2 / num1)

def main():
    number = input("value")
    answer = BSformula(number)
    print(answer)
main()   

When I run it it always prints “None”

>>>
value: 6
None
>>>

How would I assign the answer to a variable?
or can I only print it in the def BSformula??

Asked By: user5416120

||

Answers:

Just use the keyword return.

def BSformula(num1):
    """my formula"""
    return (num1 - 2.0) * (2 / num1)
Answered By: lilezek
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.