-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathString.py
More file actions
56 lines (40 loc) · 835 Bytes
/
Copy pathString.py
File metadata and controls
56 lines (40 loc) · 835 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
s = "Hello Python" #Singline string
print(s)
print(type(s))
#Multiple line strings
#Mainly used for comments
s = '''This is a
Multiple line
string'''
print(s)
s = '''It is 'a good' "example" '''
print(s)
#Next line
print('\n \n')
#String Format for left/right/center justified
s = 'Hello Python'
#Left Justified
s1 = format(s,'-<20')
print(s1)
# Right Justified
s1 = format(s,'->20')
print(s1)
#center Justified
s1 = format(s, '-^20')
print(s1)
#String Functions
print('\n\n')
s = 'Hellopython'
print(len(s))
print(max(s)) #based on ascci value
print(min(s)) #based on ascii value
#String indexing
print(s[1]) #first character
print(s[-1]) #last character
#String slicing
print(s[0:4])
print(s[::2]) #every second character select
#String functions
print(s.index('h'))
print('\n')
print(s.count('h'))