-
Notifications
You must be signed in to change notification settings - Fork 0
/
strmthds.py
45 lines (32 loc) · 874 Bytes
/
strmthds.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
str="tech is BEST @19 #101"
#methods
#returns size of given str
size=len(str)
print(size)
#returns an index of given str
print(str.index("@19") )
#checking all chars are alphabets or digits
print(str.isalnum() )
#checking all chars are alphabets
print(str.isalpha() )
#checking all chars are digits
print(str.isdigit() )
#checking all chars are digits
print("5050".isdigit() )
#checking all chars are in upper case
print(str.isupper() )
#checking all chars are in lower case
print(str.islower() )
#checking all chars are space
print(" ".isspace() )
#replecing old str with new new str
print(str.replace("@19",'@2019') )
#capitalize
print(str.capitalize() )
#swapping case
print(str.swapcase() )
#counting no of occurances
print(str.count('1') )
#splitting str by delimiter
tokens= str.split(" ")
print(tokens)