sum() is a built-in function which gives you the sum for an iterable, like a list.
To just add numbers together, use
See the official documentation for the built-in
Accordingly, if you wanted to use it to add
return the result, you could place them in a
list, as follows …
return sum([x, y])
… or in a
tuple, like this …
return sum((x, y))
However, @stetim94’s solution makes the most sense.
The official Python web site is a good place to go for documentation.
See Python: Numeric Types for information on numeric operators and several functions.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.