• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in Python by
Q:
How can you capitalize the first letter of a string?

2 Answers

0 votes
by

We can use the capitalize() function to capitalize the first character of a string. If the first character is already in capital then it returns the original string.

Syntax: string_name.capitalize() ex: n = “greatlearning” print(n.capitalize())

o/p: Greatlearning

0 votes
by

In Python, you can use the capitalize() method to capitalize the first letter of a string. However, if a string already consists of a capital letter at the beginning, it will return the original string.

Related questions

0 votes
asked Mar 20, 2021 in JavaScript by sharadyadav1986
0 votes
asked May 17, 2020 in Python by SakshiSharma
...