-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patharrays.py
More file actions
41 lines (38 loc) · 786 Bytes
/
Copy patharrays.py
File metadata and controls
41 lines (38 loc) · 786 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
# define, overriding, adding, reverse array, count of value in array,
# insert value in an array, copy array, index of array, clear array, extend another array's value
y = ['sdf', 'asdf']
y[0] = 'cars'
y[1] = 'bikes'
y.append('motor')
y.append('cycle')
y.append('travel')
y.pop(2)
y.remove('cars')
y.reverse()
y.insert(0, 'sams')
print(y)
print(y.index('sams'))
print(y.count('cycle'))
k = y.copy()
print(y.clear())
y.append('new')
print(k)
y.extend(k)
print(y)
# init 5 index with same value
k = ["last"] * 5
k[0] = "one"
k[1] = "two"
k[2] = "three"
print(k)
# declare and insert values in an array
a = []
a.append('first item')
a.append('second item')
print(a)
# replace an existing array index value
a = []
a.append('first item')
a.append('second item')
a[1] = 'replaced'
print(a)