Sum Any Number of Scores

Easy ⏱ 8 min 82% acceptance ★★★★★ 4.8
Write a function total_score(*scores) that accepts any number of numeric arguments and returns their sum. Calling it with zero arguments should return 0.

Examples

Example 1
Input
total_score(10, 20, 30)
Output
60
Explanation

Sum of the three scores.

Example 2
Input
total_score()
Output
0
Explanation

No scores means the sum is 0.

Constraints

  • Any number of arguments (including none) may be passed.
  • All arguments are numbers.

Topics

Functions*args

Companies

MicrosoftFlipkart

Hints

Hint 1

Use *scores to collect a variable number of positional arguments into a tuple.

Hint 2

sum() works directly on that tuple.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.