Write Python program to demonstrate string built-in functions
Write Python program to demonstrate string built-in functions |
Example
1.Write an program to perform all string built-in function.
str = "python programming language"
print("Capitalize function :",str.capitalize())
print("count function :",str.count("python"))
print("endswith function :",str.endswith("language"))
print("find function :",str.find("programming"))
print("index function :",str.index("programming"))
print("isdigit function :",str.isdigit())
print("isspace function :",str.isspace())
print("replace function :",str.replace("python","java"))
print("split function :",str.split())
print("upper function :",str.upper())
print("title function :",str.title())
print("strip function :",str.strip())
print("startwith function :",str.startswith("python"))
string = input("enter the string :")
num1=0
num2=0
for i in string:
if(i.islower()):
num1=num1+1
elif(i.isupper()):
num2=num2+1
print("number of lowercase character is :",num1)
print("number of uppercase character is :",num2)