top of page

1. String Methods

What are String Methods?

There are multiple functions you can apply to strings. In this lesson, we will go over them and explain them to you. You can refer back to this page if you forget any of these!

How do you use String Methods?

To use string methods, all you have to do is call the string, add a dot after that and call the name of the function you would like to use.

z = "Hello"
z.
StringMethodName()

In the example above, we referred back to the name of the variable and applied the string method on the variable.

However, you can also apply methods directly to a string as well!

All String Methods

Here is a list of all the string methods found in python. Refer back to this anytime you need to!

capitalize()

Converts the first character to uppercase.

center()

Returns a centered string.

encoded()

Returns an encoded version of the string.

expandtabs()

Sets the tab size of the string.

casefold()

Converts the string into lowercase.

count()

Returns the number of times a specified value occurs in a string.

endswith()

Returns true if the string ends with the specified value.

find()

Searches a string for a specified value and returns the position where it was found.

format()

Formats specified values in a string.

  • Instagram
  • Twitter
  • YouTube
bottom of page