def divide_by_2(number):
number /= 2
...
def main():
n = 42
divide_by_2(n)
print(n)
The result is 42, not 21. Why is this the case? Thanks in advance.
You have to return the value from your function
def divide_by_2(number):
return number / 2 # return the calculation
...
def main(n):
n = divide_by_2(n)
print(n)
>> 21
main(42) # call main with variable number