str.capitalize
does exactly what you need.
capitalize(...)
S.capitalize() -> string
Return a copy of the string S with only its first character
capitalized.
Related is
title(...)
S.title() -> string
Return a titlecased version of S, i.e. words start with uppercase
characters, all remaining cased characters have lowercase.
Note that capitalize
makes all the following letters lowercase. ie equivalent to
string[0].upper() + string[1:].lower()
.
So if you need to preserve the case of those, you'll need to stick to your original solution
>>> "fOO".capitalize()
'Foo'