How to downcase the first character of a string?

Viewed 60261

There is a function to capitalize a string, I would like to be able to change the first character of a string to be sure it will be lowercase.

How can I do that in Python?

9 Answers

This duplicate post lead me here.

If you've a list of strings like the one shown below

l = ['SentMessage', 'DeliverySucceeded', 'DeliveryFailed']

Then, to convert the first letter of all items in the list, you can use

l = [x[0].lower() + x[1:] for x in l]

Output

['sentMessage', 'deliverySucceeded', 'deliveryFailed']
Related