-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.py
More file actions
76 lines (53 loc) · 1.95 KB
/
list.py
File metadata and controls
76 lines (53 loc) · 1.95 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
cities = ['davao', 'manila', 'cebu', 'digos', 'midsayap', 'pigawayan'];
def cities_append(cities):
mycities = ['calinan', 'baguio'];
# this will check cities if calinan and baguio are present in the list
# if not it will add the mycities in the cities list
if mycities not in cities:
cities.append(mycities)
print cities
cities_append(cities);
def cities_extend(cities):
# yourcities has default value of empty []
yourcities = []
if yourcities not in cities:
yourcities = cities.extend(['cotabato','catalunan'])
print "this will add cotabato and catalunan in thse citiest list using extend", cities
return
cities_extend(cities);
def cities_insert(cities):
# if cities len is greater than 5 it will add tamayong at index two
insert_city = len(cities)
if insert_city > 5:
insert_city = cities.insert(2, "tamayong")
print "This will insert tamayong at index 2", cities
else:
print "cities less than 5"
return insert_city
cities_insert(cities);
def cities_remove(cities):
tamayong = "tamayong"
# if tamayong is in the list this will remove tamayong
if tamayong in cities:
city = cities.remove(tamayong)
print "this will remove tamayong in the list", cities
else:
print "No tamayong to delete"
cities_remove(cities)
def cities_pop(cities):
big_city = [];
for big_city in cities:
if big_city == "davao":
big_city = cities.pop(0)
print "this will remove davao at 0 index ", cities
return big_city
cities_pop(cities)
def cities_reverse(cities):
city = 10
city_length = len(cities)
if city_length < city:
city = cities.reverse();
print "This will reverse the of order of the list", cities
else:
print "list order never change"
cities_reverse(cities)