String methods are working on the string its called from, if you have a string called, string = “Hello World”, then the string method is called such this: string.string_method() . For a list of string methods, please look at one of my post covering Built In Methods in Strings.
Let’s have some fun now and show some examples:
string = "Hello World" print string.isupper() print string.upper() print string.islower() print string.isupper() print string.capitalize() print string.split() print string.split(',') print string.title() print string.strip()
- Python’s string.replace() Method – Replacing Python Strings
- Python Programming – String Functions and Methods
- Booleans, True or False in Python
If you run that, it should give you an output like this:
False HELLO WORLD False False Hello world ['Hello', 'World'] ['Hello World'] Hello World Hello World