Dan Dan - 5 months ago 63
Python Question

Capitalize a string

Does anyone know of a really simple way of capitalizing just the first letter of a string, regardless of the capitalization of the rest of the string?

For example:

asimpletest -> Asimpletest
aSimpleTest -> ASimpleTest

I would like to be able to do all string lengths as well.


@saua is right, and

str = str[:1].upper() + str[1:]

will work for any string