Editor

Multiply All Arguments

#15 · Functions · Intermediate · 55 XP · about 5 min

Write a function called multiply_all(*args) that takes any number of arguments and returns their product (all multiplied together).

Example

multiply_all(2, 3)           # Returns 6
multiply_all(1, 2, 3, 4)     # Returns 24
multiply_all(5)              # Returns 5
multiply_all()               # Returns 1 (empty product)

Requirements

  • Use *args to accept any number of arguments
  • Return 1 if no arguments are provided (empty product)
  • Handle both positive and negative numbers

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.