what is the difference between methods and functions in Python

theritically, i want to know the differences

  • Rama
  • 15 Aug
  • 1500 Views
  • 37 Answers
Your Answer

The main difference is where they live. Function: A standalone block of code. You call it by its name. Example: print("Hello") Method: A function that "belongs" to an object. You call it using a dot. Example: my_list.append(5) (The append method belongs to the list object).

Python

Didn't get the answer.
Contact people of Talent-Python directly by clicking here