The syntax of sum() is:
The sum() function adds start and items of the given iterable from left to right.
The sum() function returns the sum of start and items of the given iterable.
numbers = [2.5, 3, 4, -5] # start parameter is not provided numbersSum = sum(numbers) print(numbersSum) # start = 10 numbersSum = sum(numbers, 10) print(numbersSum)
When you run the program, the output will be:
If you need to add floating point numbers with exact precision then, you should use
If you need to concatenate items of the given iterable (items must be string), then you can use join() method.
Visit this page to learn about, Python join() Method