Order Summary With Mixed Arguments

Medium ⏱ 12 min 50% acceptance ★★★★☆ 4.3
Write a function order_summary(customer, *items, **extras) that returns a dict with keys "customer" (the customer name), "items" (a list of the positional item names, in order), and "extras" (a dict of any extra keyword info such as discount or notes).

Examples

Example 1
Input
order_summary("Neha", "Pizza", "Coke", discount=10)
Output
{'customer': 'Neha', 'items': ['Pizza', 'Coke'], 'extras': {'discount': 10}}
Explanation

Positional args after customer become items; keyword args become extras.

Constraints

  • customer is always provided.
  • Zero or more item names and zero or more keyword extras may follow.

Topics

Functions*args and **kwargs

Companies

AmazonSwiggyZomato

Hints

Hint 1

*items becomes a tuple — convert it to a list.

Hint 2

**extras is already a dict; wrap the three pieces in one result dict.

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