Chrome Extension

[Python] Default value of function argument

# Example demonstrates usage of  function arguments default values

def foo(filename='testid', flag = True, number = None):
    pdf_file = filename + ".pdf"
    print(f'\n Filename =  {pdf_file}, Flag = {flag}, number = {number}')


if __name__ == '__main__':
    foo()
    foo("readme", False, 4)
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Output
Filename = testid.pdf, Flag = True, number = None

Filename = readme.pdf, Flag = False, number = 4
Was this helpful?
0 Comments
Join Devsheet Ask a Question