-
Notifications
You must be signed in to change notification settings - Fork 8
/
string_methods.py
56 lines (44 loc) · 1.21 KB
/
string_methods.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Strings are immutable
a = "!!!Harry!! !!!!!!!!! Harry"
print(len(a))
print(a)
print(a.upper())
print(a.lower())
print(a.rstrip("!"))
print(a.replace("Harry", "John"))
print(a.split(" "))
blogHeading = "introduction tO jS"
print(blogHeading.capitalize())
str1 = "Welcome to the Console!!!"
print(len(str1))
print(len(str1.center(50)))
print(a.count("Harry"))
str1 = "Welcome to the Console !!!"
print(str1.endswith("!!!"))
str1 = "Welcome to the Console !!!"
print(str1.endswith("to", 4, 10))
str1 = "He's name is Dan. He is an honest man."
print(str1.find("ishh"))
# print(str1.index("ishh"))
str1 = "WelcomeToTheConsole"
print(str1.isalnum())
str1 = "Welcome"
print(str1.isalpha())
str1 = "hello world"
print(str1.islower())
str1 = "We wish you a Merry Christmas\n"
print(str1.isprintable())
str1 = " " #using Spacebar
print(str1.isspace())
str2 = " " #using Tab
print(str2.isspace())
str1 = "World Health Organization"
print(str1.istitle())
str2 = "To kill a Mocking bird"
print(str2.istitle())
str1 = "Python is a Interpreted Language"
print(str1.startswith("Python"))
str1 = "Python is a Interpreted Language"
print(str1.swapcase())
str1 = "His name is Dan. Dan is an honest man."
print(str1.title())