Skip to content
Advertisement

Python function make parameter mandatory if another parameter is passed

I have a function in Python as

JavaScript

Is there a way to ensure that if the user passes the value of the parameter b it is necessary to pass the parameter c to myfunc?

Advertisement

Answer

You can write a simple if condition in your function. See the code below:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement