Default Arguments

3. Default Arguments

  • We can mention some default value for the function parameters in the definition. Let's take the definition of grocery() function.

  • Sometimes we can provide default values for our positional arguments.  

  • If we are not passing any name then only default value will be considered. 

***Note: After default arguments we should not take non default arguments

                   def wish(name="Guest",msg="Good Morning"): ===>Valid
                   def wish(name,msg="Good Morning"): ===>Valid
                   def wish(name="Guest",msg):  ==>Invalid 

SyntaxError: non-default argument follows default argument. 

Comments