Change Python string to lower case
Using string lower method
The lower method changes to string to lower case. It has the following syntax.
s.lower()
Converts all letters to lowercase.
print 'Java2s.COM'.lower()
The code above generates the following result.
quote = "Python is easy to use."
# from ww w . ja v a 2 s . c om
print quote
print quote.lower()
print quote
The code above generates the following result.
lower()
function is useful when doing the searching.
if 'Python' in ['python', 'Java', 'C#']: print 'Found it!'
# from ww w . ja v a2 s. co m
name = 'Python'
names = ['python', 'Java', 'C#']
if name.lower() in names: print 'Found it!'
The code above generates the following result.