I am writing a new python class with a generic function. At one point I have a requirement as follows
def function(a=1):
....
....
print a # here I want a to be 1 if None or nothing is passed
Eg:
Is there a way to do this?
You can define a function with a default argument, later you can check for the value passed and print it:
def fun(a=1):
a = 1 if a is None else a
print(a)