-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_list.py
More file actions
32 lines (22 loc) · 748 Bytes
/
04_list.py
File metadata and controls
32 lines (22 loc) · 748 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
# Lists are mutable
# Lists are a container to store a element of same datatype
store = ["Apple","Mango",False,5,4.3,"Rishav"]
l1 = [1.4,9,23,8,12,44]
print(store[2])
store[0] = "Hero" #list can be change as they are mutable
print(store[0])
# indexing in list
print(store[0:3])
# Inbuilt functions in List
store.append("Added") #add the element at the end of the index
print(store)
l1.sort() # Sorts the list
print(l1)
l1.reverse() #Reverses the list
print(l1)
l1.insert(3,"Hola") #inserts the value at desired index
print(l1)
print(l1.pop(3)) #show the element to remove
print(l1) # remove the value at given index and the rest element are returned
l1.remove(44) # remove the given element
print(l1)