Post

PythonPython

T
Tom 234

Posted on 19th April 2024|46 views

0
votes

Python Optional Arguments

How to create a python function with optional arguments?

Answers
P
Tim Parker

Posted on 19th April 2024

We can utilise the parameter of *args, that permits you to transfer as many arguments as you need. For example:

 

def myfunc(u,v, *args, **kwargs): 

for ar in args: 

print ar 

myfunc(u,v,w,x,y,z)

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos