Python Guide #13: Object Methods

Objects can contain methods within themselves. For example string objects let you execute methods on them, they can be capitalized, trimmed and joined and many more.

To access objects method, you use variable name, under which object is stored, followed by a “.”.

my_string = "This is a sample string"
print(my_string.replace(" ", "-"))

Execute program above and see what happens.

Next: Python Guide #14: Classes

Previous: Python Guide #12: Writing to Files