Python string lowercase and uppercase

To convert a string to lowercase of uppercase following code can be used:

s_lower = s.lower()
s_upper = s.upper()

string lowercase example

s = "Hello Python"
s2 = s.lower()
print s
print s2
Hello Python
hello python
Env: Python 2.7.6

string uppercase example

s = "Hello Python"
s2 = s.upper()
print s
print s2
Hello Python
HELLO PYTHON
Env: Python 2.7.6
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments