0
How do I use optional arguments in python?
I'm making a function for a homework that use 3 arguments but only 2 are strictly needed, is there a way to make the function work if the user forget to give the third argument?... sorry for my english by the way
1 Resposta
+ 1
def myfunction(needthis, needthis2, optional=1):
Basically set the optional argument to a default value and if you only pass two arguments optional is set to the default (in this case 1)