Question

In Python, how to capitalize the first and only the first character of a string?


Annonce
Ad

Answer

>>> def upperFirst(s):
...     return s[0].upper() + s[1:]
... 
>>> upperFirst('hello world')
'Hello world'


[source]
# ID Query