-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayInsertion.py
More file actions
39 lines (29 loc) · 818 Bytes
/
Copy patharrayInsertion.py
File metadata and controls
39 lines (29 loc) · 818 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
arr = [1, 2, 3, 4, 5, 6]
arr.insert(6, 7)
print("printing array: ", arr)
# accessing element
print("accessing element of array.")
def accessesElement(array, index):
if index >= len(array):
print("There is not any element in this index.")
else:
return array[index]
print(accessesElement(arr, 3))
# traverse array
print("\ntraverse array")
def traverseArray(arrays):
for i in arrays:
print(i)
traverseArray(arr)
# Searching element in the array
print("Searching element in the array")
def searchElement(array, value):
for i in array:
if i == value:
return array.index(value)
return "does not exist"
print(searchElement(arr, 4))
# Delete Element from array
print("Deleting element")
arr.remove(3)
print(arr)