Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

I have a script which reads the input and then lists it, however, I want it to convert upper case letters to lower case, how can I do that?

this is what I got

for words in text.readlines(): 

sentence = [w.strip(',.') for w in line.split() if w.strip(',.')] 

list.append(sentence)

2 Answers

0 votes
by (106k points)

You can use str.lower(), it converts all cased characters to lowercase.

0 votes
by (20.3k points)

Try using the code given below:

w.strip(',.').lower()

For more information, you can refer to this link:

https://docs.python.org/3/library/stdtypes.html#string-methods 

Related questions

+3 votes
2 answers
0 votes
1 answer
asked Feb 17, 2021 in Java by Jake (7k points)
0 votes
4 answers
0 votes
2 answers
0 votes
1 answer
asked Apr 13, 2021 in Java by sheela_singh (9.5k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...