If you have started learning Python after working in Java for many years you would have wondered over one thing; while in Java you always call an enclosed group of statements doing a specific task a method, in Python you would have noticed use of both functions and methods. If you think both terms can be used interchangeably then you must know there is a subtle difference between function and method in Python and that’s what is the topic of this post.
Function Vs Method in Python
While both function and methods in Python are written the same way as given below-
def function_name(param1, param2, ..) : """function doc string""" function suite
How these two differ is that a function in Python is a group of statements that can be written individually in a Python program. You can call that function using its name and passing arguments if any.