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:
False HELLO WORLD False False Hello world ['Hello', 'World'] ['Hello World'] Hello World Hello World
Recommended Python Training
Course: Python 3 For Beginners
Over 15 hours of video content with guided instruction for beginners. Learn how to create real world applications and master the basics.