Home > front end >  python function: how to unset a default argument value
python function: how to unset a default argument value

Time:11-19

if i have

def (a=10, b=2): ...

how do I unset a=1? I was told I need to not set 'a' but I can't find how to do that on google, it just sets itself to the default value if I don't have it, and I need to completely unset it

CodePudding user response:

Simply pass new values to your function on call:

def func(a=10, b=2)
   print(a, b)

Call with default arguments:

func()

Call with non-default arguments:

func(20, 3)

CodePudding user response:

answer is that I had to set it to None and it worked

  • Related