-
Notifications
You must be signed in to change notification settings - Fork 2
/
StringMethod.py
78 lines (49 loc) · 1.15 KB
/
StringMethod.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
spam = 'Hello Friends'
print(spam.upper())
demo = 'HELLO FRIENDS'
print(demo.lower())
spam = 'HELLO WORLD !'
demo = 'hello world...!'
print(demo.islower())
print(spam.isupper())
print('Hello'.upper().isupper())
# isalpha()
# isalnum()
# istitle()
# isspace()
# isdigit()
# isdecimal()
print('hello'.isalpha())
print('hello'.isalnum())
print('Hello Friends How Are You...?'.istitle())
print('hello world'.title())
print('Hello World'[5].isspace())
print('13456'.isdecimal())
# startwith()
# endwith()
print('Hello...'.startswith('H'))
print('How are you...'.endswith('.'))
# join()
# Convert Array into String
spam = ['Cat', 'Dog', 'Monkey', 'Cow', 'Buffelo']
print(','.join(spam))
demo = '\n\t'.join(spam)
print(demo)
# split()
print('My name is Vishal Rathod'.split(' '))
# ljust() left Justify
# rjust() Right Justify
print('hello'.rjust(50 , '*'))
print('Hello'.ljust(45, '-') + 'hello')
# Center()
name = input()
print('Helllo'.center(40))
print(name.center(50, '='))
# strip()
# rstrip()
# lstrip()
spam = 'Hello'.rjust(10)
print(spam)
print(spam.strip())
print(' Vishal '.strip())
print(' Vishal '.rstrip())