Python String Methods are built-in functions that allow us to manipulate strings. They are used to perform various operations on strings such as searching, replacing, splitting, and formatting.
1. capitalize()
This method capitalizes the first letter of a string.
Example:
str = "python programming" print(str.capitalize())
print(str.count("a"))
str = "Python is a programming language" print(str.endswith("language"))
str = "Python is a programming language" print(str.find("a"))
str = "My name is {name}" print(str.format(name="John"))
str = "Python is a programming language" print(str.index("a"))
str = "Python123" print(str.isalnum())
print(str.isalpha())
str = "12345" print(str.isdigit())
str = "-" list = ["Python", "Programming", "Language"] print(str.join(list))
Disclaimer:
Patodia Infotech Private Limited (fastdevai.com) has no responsibility for any text or code generated or for any action taken by you based on the contents provided by this web site. The use of this web site is solely at the user's risk. All the services are provided with the understanding that Patodia Infotech Private Limited or any other person or company associated with this company or website are not responsible for any loss or damage occurring to anybody from any code or contents generated by this website. Please note that text, codes and contents are generated by AI. These are state-of-the-art AI solutions. However, these are AI tools so there is no guarantee of accuracy of any code or contents generated.