-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString task.py
More file actions
108 lines (45 loc) · 1.01 KB
/
Copy pathString task.py
File metadata and controls
108 lines (45 loc) · 1.01 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python
# coding: utf-8
# indexing and sliing of String
#
# In[1]:
myString = 'Hello World'
# In[2]:
myString[1]
# In[3]:
myString[3]
# In[4]:
#last letter
myString[-1]
# Now Slicing
# In[5]:
myString = 'abcdefghk'
# In[6]:
myString[2]
# In[7]:
myString[2:]
# In[8]:
myString[:3]
# # start point include in string but final point doesnt
# myString[3:6]
# In[10]:
myString[1:3]
# Now Use Step Size
# [start:final:step]
# In[16]:
#that means parse the string but jump to 2 means step size 2
# a->b->c print c after a -> means step size
myString[::2]
# In[17]:
myString[::3]
# # all combining example
# In[19]:
# 1 start index that is b includes as I mentioned above , 6 is final point that is 'g' but g not includes so our string will be b,c,d,e,f
# b,c,d,e,f
# now that string will parse with step size b->c->d = bd that d->e->f the answer will be bdf
myString[1:6:2]
# for reverse string
# In[21]:
# parse string reversely
myString[::-1]
# In[ ]: