Home > database >  How do I only change first letter into a capital using ascii in python
How do I only change first letter into a capital using ascii in python

Time:03-16

The code I currently have makes it so that the entire word is capitalised instead of just the first letter which is what I am trying to accomplish.

https://i.stack.imgur.com/4FgE7.png

CodePudding user response:

word = "pinklemon1998"

_word = word[0].upper()   word[1:]

Or as mentioned in the comments:

_word = word.title()

CodePudding user response:

There is a nice method for str called .capitalize()

word = "hello"
word.capitalize()
  • Related