I want a function which returns no error when we do not fill the parameter also?

Submitted 3 years, 7 months ago
Ticket #176
Views 218
Language/Framework Python
Priority Medium
Status Closed

I have the following code

def fun1(par):
    print('Hi this is a function without filling the parameter')
    return True

fun1()

And it should print the above statement but it is  showing error like:

 fun1()

TypeError: fun1() missing 1 required positional argument: 'par'

Help me out please.....

Submitted on Sep 25, 20
add a comment

1 Answer

Verified

def fun1(par=None):
    print('Hi this is a function without filling the parameter')
    return True

fun1()

so it will give you the desired output if parameter=None

Submitted 3 years, 7 months ago


Latest Blogs