How do I use optional arguments in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

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

11th Oct 2017, 10:06 PM
Daniel Andrés González Llano
Daniel Andrés González Llano - avatar
2 Answers
+ 2
def function(needed1,needed2,*optionalArgs):
11th Oct 2017, 10:22 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
0
thanks
11th Oct 2017, 10:25 PM
Daniel Andrés González Llano
Daniel Andrés González Llano - avatar