Python String inbuilt Methods
Python has a set of built-in methods that we can use on strings
upper()
The upper() method returns a string where all characters are in upper case. Symbols and Numbers are ignored.
Syntax
string.upper()
n=”hello”
print(n.upper())
output:
HELLO
n=”hello world”
n1=n.upper()
print(n1)
output:
HELLO
n="hello" print(n.upper()) n="hello world" n1=n.upper() print(n1)
Output:
HELLO
HELLO WORLD
lower()
The lower() method returns a string where all characters are in lower case. Symbols and Numbers are ignored.
Syntax
string.lower()
n=”HELLO”
print(n.lower())
output:
hello
n=”HELLO WORLD”
n1=n.lower()
print(n1)
output:
hello world
title()
The title() method returns a string where the first character in every word is upper case. Like a header, or a title.
If the word contains a number or a symbol, the first letter after that will be converted to upper case.
Syntax
string.title()
n=”HELLO HOW ARE YOU”
print(n.title())
Output:
Hello How Are You
n=”HELLO HOW ARE YOU”
n1=n.title()
print(n1)
Output:
Hello How Are You
n="HELLO HOW ARE YOU" print(n.title()) n="HELLO HOW ARE YOU" n1=n.title() print(n1) n="123 hello" print(n.title()) n="123hello" print(n.title())
Output:
Hello How Are You
Hello How Are You
123 Hello
123Hello
Python String inbuilt Methods Python Math inbuilt Methods Python Date And Time inbuilt Methods Python Random inbuilt Methods