Reputation: 11
I am learning python and I have a problem with a supposedly simple function, can anyone tell me why my function is not working?
def sum_numbers (num1, num2):
return num1 + num2
sum_numbers(10, 20)
print(sum_numbers)
Upvotes: 0
Views: 195
Reputation: 43575
Printing the name of the function probably results in something like this:
<function sum_numbers at 0x7fa7483162f0>
To print the sum of the numbers, you may either assign the result of the function to a variable and print the variable or print the function with the parameters:
def sum_numbers (num1, num2):
return num1 + num2
print(sum_numbers)
print(sum_numbers(10, 20))
result = sum_numbers(3, 5)
print(result)
Upvotes: 1