0
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??

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
  • For the record: Python 2.4.4 was released [in October 2006](https://docs.python.org/release/2.4.4/) and support for it had long ended when this question was asked - even 2.6 went end-of-life in 2013. In general, new releases of Python [are supported for about 5 years](https://endoflife.date/python). – Karl Knechtel Aug 14 '22 at 17:52

1 Answers1

1

Just use the keyword return.

def BSformula(num1):
    """my formula"""
    return (num1 - 2.0) * (2 / num1)
lilezek
  • 6,976
  • 1
  • 27
  • 45