The .title() method of a string (either ASCII or Unicode is fine) does this:

>>> "hello world".title()
'Hello World'
>>> u"hello world".title()
u'Hello World'

However, look out for strings with embedded apostrophes, as noted in the docs.

The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition works in many contexts but it means that apostrophes in contractions and possessives form word boundaries, which may not be the desired result:

>>> "they're bill's friends from the UK".title()
"They'Re Bill'S Friends From The Uk"
Answer from Mark Rushakoff on Stack Overflow
🌐
Vultr
docs.vultr.com › python › examples › capitalize the first character of a string
Python Program to Capitalize the First Character of a String
November 21, 2024 - The capitalize() method converts the first character to uppercase and all other characters to lowercase. In the example above, "hello world" becomes "Hello world". Consider scenarios where each word needs to start with a capital letter.
Discussions

python - how to change the case of first letter of a string? - Stack Overflow
s = ['my', 'name'] I want to change the 1st letter of each element in to Upper Case. s = ['My', 'Name'] More on stackoverflow.com
🌐 stackoverflow.com
How do I capitalize the first letter of a string, but have it respect forced capitalizations anyway
This keeps it pretty simple imo. We use 2 versions of the string, original and title, and zip the character pairs. Then with list concatenation, we take the min character value (i.e. prioritise uppercase). And finally join it back into a string. ''.join([min(i) for i in zip(my_str, my_str.title())]) Tried to take a short cut, didn't work :( Fixed to support all non-ascii characters ''.join([i[0] if i[0].isupper() else i[1] for i in zip(my_str, my_str.title())]) I like it because I don't have to re-create existing 'title' logic which I reckon is generally good practice for code. This also supports multiple empty characters in a row, newlines, etc. which some of the other examples here do not. More on reddit.com
🌐 r/learnpython
39
25
December 8, 2025
Changing the first letter of a string into upper case in python - Stack Overflow
I aim to convert a proper noun for instance to have an upper case first letter after an input of the name has been made. More on stackoverflow.com
🌐 stackoverflow.com
September 24, 2017
python capitalize first letter only - Stack Overflow
I am aware .capitalize() capitalizes the first letter of a string but what if the first character is a integer? this 1bob 5sandy to this 1Bob 5Sandy More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-capitalize-first-character-of-string-in-python
How to Capitalize First Character of String in Python - GeeksforGeeks
July 12, 2025 - Using str.capitalize() is a simple way to make the first character of a string uppercase while converting the rest of the characters to lowercase.
🌐
GeeksforGeeks
geeksforgeeks.org › python › string-capitalize-python
String capitalize() Method in Python - GeeksforGeeks
January 19, 2026 - Python provides the built-in capitalize() string method to convert the first character of a string to uppercase and automatically convert all remaining characters to lowercase. This method is commonly used in text formatting, data cleaning and ...
🌐
W3Schools
w3schools.com › python › ref_string_capitalize.asp
Python String capitalize() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... The capitalize() method returns a string where the ...
🌐
FavTutor
favtutor.com › blogs › capitalize-first-letter-python
8 Ways to Capitalize First Letter in Python | FavTutor
October 27, 2021 - Regex is generally known as a regular expression in python, is a special sequence of characters that helps match or find the other strings. Using regex, you can search the starting character of each word and capitalize it. For using this method, you have to import the regex library using the “import” keyword before defining the main function, as shown in the below example. Also, remember that this method only capitalizes the first character of each word in python and does not modify the whitespaces between the words. ... import re def convert_into_uppercase(a): return a.group(1) + a.group(2).upper() s = "python is best programming language" result = re.sub("(^|\s)(\S)", convert_into_uppercase, s) print(result)
🌐
LearnPython.com
learnpython.com › blog › uppercase-letter-python
How to Uppercase the First Letter of a Word in Python | LearnPython.com
May 23, 2022 - We know the capitalize() method converts only the first letter of a string to uppercase in Python. However, we can combine it with the split() method to capitalize each word. The split() method, as its name suggests, splits a string at the positions ...
Find elsewhere
🌐
Python Examples
pythonexamples.org › python-string-capitalize-first-character-of-string
Capitalize First Character of String in Python
To capitalize first character of a String in Python, i.e., transform the first character to upper case, you can use String.capitalize() function.
🌐
DEV Community
dev.to › kiani0x01 › how-to-uppercase-the-first-letter-in-python-374e
How to Uppercase the First Letter in Python - DEV Community
August 2, 2025 - It lowercases all other letters, which may not be what you want if the rest of the string has a specific case pattern. Tip: Use .capitalize() when you need a title-like format, but not if you want to preserve the original casing beyond the first letter. To uppercase only the first character and leave the rest intact, combine slicing with .upper(): text = "python" if text: result = text[0].upper() + text[1:] else: result = text print(result) # Output: Python
🌐
Note.nkmk.me
note.nkmk.me › home › python
Uppercase and Lowercase Strings in Python (Conversion and Checking) | note.nkmk.me
August 13, 2023 - You can also overwrite the original variable. s_org = s_org.upper() print(s_org) # PYTHON PROGRAMMING LANGUAGE ... The capitalize() method converts the first character of the string to uppercase and the rest to lowercase.
🌐
Reddit
reddit.com › r/learnpython › how do i capitalize the first letter of a string, but have it respect forced capitalizations anyway
r/learnpython on Reddit: How do I capitalize the first letter of a string, but have it respect forced capitalizations anyway
December 8, 2025 -

For example, "cotton tails" will be "Cotton Tails"

However, if it's COTTON TAILS, it should still be COTTON TAILS

 

I tried .title() but that capitalizes the first letter of each word but automatically sets the rest of the characters to lower case.

So "COTTON TAILS" would be "Cotton Tails" and I do not want that. I want every first letter of each word to be capitalized, but any other hard coded capitalizations should be retained.

 

ED

Thanks. for the quick replies. I will make a function for this.

🌐
Python Pool
pythonpool.com › home › tutorials › capitalize the first letter in python: unicode-safe methods
7 Ways in Python to Capitalize First Letter of a String
July 13, 2026 - This guide shows the safest options with examples you can copy into a script. The short answer is: use str.capitalize() when you want Python to uppercase the first character and lowercase the rest.
🌐
Programiz
programiz.com › python-programming › examples › capitalise-first-character
Python Program to Capitalize the First Character of a String
my_string = "programiz is Lit" cap_string = my_string.capitalize() print(cap_string) Output · Programiz is lit · Note: capitalize() changes the first character to uppercase; however, changes all other characters to lowercase. Share on: Did you find this article helpful? Python Example ·
Top answer
1 of 2
4

Use the capitalize string method on each word in the list and then join the strings together with an underscore:

>>> '_'.join(x.capitalize() for x in s)
'Smith_Jones_Paul'

In summary...

  • capitalize puts a string's first character to uppercase and the subsequent characters to lowercase.
  • (x.capitalize() for x in s) applies the capitalize to each string in your list s.
  • join takes a list (or other iterable) of strings and joins the strings together with a delimiter (in this case an underscore).

N.B. It's worth noting that passing a list to join is more efficient than giving it the generator expression shown above:

>>> %timeit '_'.join([x.capitalize() for x in s]) # list
1000000 loops, best of 3: 866 ns per loop

>>> %timeit '_'.join(x.capitalize() for x in s) # generator
100000 loops, best of 3: 2.05 us per loop
2 of 2
0

Actually, doing the "manual" work is (just a little) faster:

>>> "_".join([x[0].upper() + x[1:] for x in s])
'Smith_Jones_Paul'

Actually a bit confused with the benchmark:

>>> %timeit '_'.join([x.capitalize() for x in s])
1000000 loops, best of 3: 817 ns per loop

>>> %timeit '_'.join([x[0].upper() + x[1:] for x in s])
1000000 loops, best of 3: 796 ns per loop

The variation is really high in this case. But when I do a simple for loop for this case:

z = ["aasdfasdfasdfsadfa", "aasdfasdfasdfsadfa", "aasdfasdfasdfsadfa", 
     "aasdfasdfasdfsadfa", "aasdfasdfasdfsadfb"] * 10

for i in range(1000000): 
    a = [x[0] + x[1:] for x in z]

for i in range(1000000):
    b = [x.capitalize() for x in z]

There is a difference of 9 vs 16 seconds!

🌐
Programiz
programiz.com › python-programming › methods › string › capitalize
Python String capitalize() (With Examples)
# converts first character to uppercase and others to lowercase capitalized_string = sentence.capitalize() print(capitalized_string) # Output: I love python
🌐
Data Science Dojo
discuss.datasciencedojo.com › python
How to capitalize the first character of elements in a Pandas Series? - Python - Data Science Dojo Discussions
March 1, 2023 - @mubashir_rizvi, You can also achieve your goal by using Python built-in functions for strings. You can use the str[0].str.upper() syntax to select the first character of each element in the series and convert it to uppercase, first.