-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathS05L24_script01.py
More file actions
38 lines (21 loc) · 1002 Bytes
/
Copy pathS05L24_script01.py
File metadata and controls
38 lines (21 loc) · 1002 Bytes
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
# for testing methods
a = "hello"
b = "happy biRthday"
print("original a:" "{}".format(a))
print("original b:" "{}".format(b))
# Example of methods
#index method, will return the starting position of the pattern inside the string
print(b.index("biRthday"))
#if the pattern wont be found it will return ValueError
#print(b.index("tirhtrhtkjrtre"))
#find method, it will nearly the same as index, but instead of giving an error whenver the patter is not found it will return a -1
print(b.find("jfkdjfkdj"))
#strip method is deleting from the strip the specified pattern So if we hae
y = "000000happyBirthday0000000"
print("y = " "{}".format(y))
print("b = " "{}".format(b))
print('y.strip("0") = ' "{}".format(y.strip("0")))
print('b.strip() = ' "{}".format(b.strip()))
# lstrip and rstrip is removing the specified pattern as strip, but from the left and the right respectively
print('y.lstrip("0") = ' "{}".format(y.lstrip("0")))
print('y.rstrip("0") = ' "{}".format(y.rstrip("0")))