Basic String Methods
Basic String Methods
Every time you see ()
we are working with a function
or a method
()
we are working with a function
or a method
Difference between function and Method:
if there is a
.
before the word then it is a methodexample:
sentence.upper()
methods also are associated with an object
if it is stand alone then it is a function
example:
print()
functions are stand alone
Some Types of methods:
.upper
- Uppercase letters.lower
- Lowercase letters.capitalize
- Capitalizez first letter and lowercase the rest.isdigit
- Checks if the string is a digit and returns a boolean value (True or False)There are multiple methods starting with
is
- Used to check:is something like that?
There are multiple methods starting with
startswith()
expects string
Similar to
startswith
there is alsoendswith()
expects string
Last updated