Python String Methods

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()

If you run that, it should give you an output like this:

Hello world
['Hello', 'World']
['Hello World']
Hello World
Hello World

Leave a Reply

Your email address will not be published. Required fields are marked *