I have this:
word = raw_input("enter a word")
word[0].upper()
But it still doesn't make the first letter uppercase.
I have this:
word = raw_input("enter a word")
word[0].upper()
But it still doesn't make the first letter uppercase.
.upper()
returns a new string because strings are immutable data types. You ought to set the return value to a variable.
You can use .capitalize
over .upper
if you want to make only the first letter uppercase.
>>> word = raw_input("enter a word")
>>> word = word.capitalize()
Please note that .capitalize
turns the rest of the characters to lowercase. If you don't want it to happen, just go with [0].upper()
:
word = word[0].upper() + word[1:]