How can I mix multiple and optional arguments in Python?

Viewed 45

I want to write function with default and multiple arguments. Now I have somethink like this:

def make_pizza(size=10, *toppings):
    for t in toppings:
        print("-",t)

    print('Pizza has', size, 'cm')

and later I try to call:

make_pizza(30, 'pepperoni')
make_pizza('pepperoni')
make_pizza(50, 'cheese', 'cucumber', 'chilli')

but results looks bad:

- pepperoni Pizza has 30 cm Pizza has pepperoni cm - cheese - cucumber - chilli Pizza has 50 cm

What should I do, if I want print '10' instead pepperoni in third line?

1 Answers
Related