Method

A Methods is like functions except that it’s called on a value.

Example using index() function.

>>> spam = ['hello', 'hi', 'howdy', 'heyas']
>>> spam.index('hello')
0
>>> spam.index('heyas')
3

Note the syntax is value.method(someDataType)

  • Unlike functions methods don’t return a value .
  • Methods belong to a single date type.
    • For example: lists, strings, etc.