forked from kishanrajput23/Awesome-Python-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.py
More file actions
18 lines (11 loc) · 680 Bytes
/
list.py
File metadata and controls
18 lines (11 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# list : a single variable that can take many values called elements
x= [2, 5, 8, 6, 0] #list intergers
y = ['Max', 5, 3.2, [2, 4]] ##it is possible to save multiple data types values in a list
z = ['Max', 'Jhon', 'peter', 1]
print(y[0]) #print out the value of the first element at first index from the list y
print(y[3])
print(z[2])
#insert and remove from a list
print(x.insert(2, 'Tome')) #at position two in the list x, Tom is inserted
print(z.remove('Jhon')) #Jhon is to be remove from the list z
w = z.copy() #this copy the content of z into the list of w