cadams
cadams

Reputation: 1415

Is there any way to choose if a default parameter is used for a function?

For example:

def tune(a=2,b=3,c=4):
    return str(a) + " " + str(b) + " " + str(c) 

print tune(5, *default*, 7)

so that the output would be:

5 3 7

What do I put in place of the *default* to make this happen?

Upvotes: 1

Views: 45

Answers (1)

Bhargav Rao
Bhargav Rao

Reputation: 52191

Use default named arguments. Explicitly mention that c has to take the value of 7

>>> print tune(5, c= 7) 
5 3 7

Upvotes: 6

Related Questions