capitalize() : First char of input string is changed to Upper case.

my_str="welcome to plus2net.com"
print(my_str.capitalize()) # Welcome to plus2net.com
We can't change the first char if it is a number
my_str="345 is the number"
print(my_str.capitalize()) # 345 is the number
capitalize()

Parameters

No parameter is taken by this method.

capitalize(),title() & upper()

capitalize() only changes the first character, while title() capitalizes each word, and upper() converts all characters to uppercase.
text = "hello world"
print(text.capitalize())  # Hello world
print(text.title())       # Hello World
print(text.upper())       # HELLO WORLD
Handling Special Characters:
text = "@welcome"
print(text.capitalize())  # @welcome (special character remains unchanged)
Applying to Multi-sentence Strings:
text = "hello. this is a test."
print(text.capitalize())  # Hello. this is a test.

All String methods


Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer