0
What happens with this code?
Output is some unintelligible string of numbers and letters, for example "<function total at 0x71a634dd30d0>" with input of 24 used for simple multiplication. It doesn't get any better with any other input. The code: https://www.sololearn.com/en/compiler-playground/cSqRky5VkXpb
3 Réponses
+ 4
You have a mistake in your code. You're printing the function object and displaying its address in memory. To correct the mistake you have to include the arguments in your code.
bill = total(price, count)
print(bill)
+ 4
Let me add a little background to Chris Coder's answer.
What your code "bill = total" doing is assigning a function to a variable.
That is creating an alias of the total() function.
If keeping your code unchanged, below lines produce the same result.
print(total(price = 10.35, count = 10)) # 103.5
print(bill(price = 10.35, count = 10)) # 103.5
+ 1
Try it with this line:
bill = total(price, count)