Home » Python

Python String | capitalize() Method with Example

Python string | capitalize() Method with Example, it is an in-built method in Python and it is used to return capitalized string.
Submitted by IncludeHelp, on July 18, 2018

capitalize() is an in-built method in Python, it returns the string in Capitalized case, in which first character of the sentence is in uppercase and rest of the characters are in lowercase.

Syntax:

 String.capitalize()

Parameter: None

Return type: It returns capitalize case string.

Example:

# str1
str1 = "Hello world, how are you?"
print str1.capitalize ()

# str2
str2 = "HELLO WORLD, HOW ARE YOU?"
print str2.capitalize ()

# str3
str3 = "hello world, how are you?"
print str3.capitalize ()

#str4
str4 = "100google is a website"
print str4.capitalize ()

Output

    Hello world, how are you?
    Hello world, how are you?
    Hello world, how are you?
    100google is a website




Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.