-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlists.py
More file actions
58 lines (32 loc) · 904 Bytes
/
lists.py
File metadata and controls
58 lines (32 loc) · 904 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
42
#using the list constructor to create a list
cars =list(("nissan","audi","bmw","toyota","mazda","benz"))
print (cars)
print (cars[-2])
print (cars[0:5])
if "toyota" in cars:
print ("yes toyota is there")
if "Royce" in cars:
print("yes its there")
else:
print ("tswayi kayikho")
######################################
friends=["terence",'tendai','mpofu','geogre','michael']
friends[1]="chris"
friends.insert(3,"kevin")
print (friends)
thislist = ["apple", "banana", "cherry"]
thislist.insert(2, "watermelon")
print(thislist)
thislist.append("orange")
print(thislist)
cars=list(("nissan","audi","bmw","toyota","mazda","benz"))
thislist = ["apple", "banana", "cherry"]
cars.extend(thislist)
print(cars)
thislist = ["apple", "banana", "cherry"]
thistuple=("kiwi",'orange')
thislist.extend(thistuple)
print(thislist)
del thislist[2]
print(thislist)
print(thislist.pop())