Earn 20 XP


image.png

  • You might have a question bugging you: “Why on Earth do we have both functions and methods, when they practically do the same thing?”

  • Firstly, let's start with the obvious. There is a clear difference in the syntax:

    • A function looks like this: function(something)
    • And a method looks like this: something.method()
  • Namely: a method always belongs to an object (e.g., in the x.index(2) method, .index() needed the x object to be applicable), while a function doesn’t necessarily depend on a Python object.

  • All methods are functions, but not all functions are methods!

  • If this makes no sense to you (yet), don’t you worry. I promise, the idea will grow on you as you use Python more and more – especially when you start to define your own functions and methods.

image.png