-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringmethods.py
More file actions
12 lines (11 loc) · 790 Bytes
/
stringmethods.py
File metadata and controls
12 lines (11 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
name= "blacK body"
print(len(name))#this method is used to calculate the length of a string. it also counts the number of spaces
print(name.find("k"))#it finds the postion of a character in a string
print(name.capitalize())# it only capotalises the first letter
print(name.upper())#it capitalises the case of all characters of a string
print(name.lower()) #it lowers the case of all charaters in a string
print(name.isdigit)#it checks if the string is only made figures
print(name.isalpha)#it checks if the string is made up of only charaters.it doesnt consider a space as an alpha
print(name.count("a"))#it counts the number of times the charater appears
print(name.replace("b","w"))#replaces a charater with another character in a string
print(name*3)#this prints the string three times