Header Ads

Responsive Ads Here

String Methods

 String Methods



name = "Adrika bhadauria"

print(len(name))   # Gives the length of string

print(name.lower())  # Converts the string into lower case

print(name.upper())   # Converts the string into upper case

print(name.title())   # Converts first letter of each word to upper case

print(name.capitalize())#Converts first letter the whole string to upper case

print(name.index("r"))  # Gives the index of sub-string

print(name.isupper())  # Returns True if string is upper cased else false

print(name.islower())   # Returns True if string is lower cased else false

print(name.count("a"))  # Counts the number of sub-strings

Powered by Blogger.