-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice_python _lists.py
More file actions
91 lines (37 loc) · 1.29 KB
/
practice_python _lists.py
File metadata and controls
91 lines (37 loc) · 1.29 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Lists!
# Fine a list with cool things inside!
# Examples: Christmas list, things you would by with the lottery
# Christmas_list = ['ipad', 'iphone', 'Nike Air Max', 'Honey Jack Daniels', 'A trip to Vegas']
# It must have 5 items
# Complete the sentence:
# Lists are organized using: #
example_xmas = ['walkie talkies', 'socks', 'lynx']
# Print the lists and check it's type
print(type(example_xmas))
# Print the list's first object
print(example_xmas[0])
# Print the list's second object
print(example_xmas[1])
# Print the list's last object
print(example_xmas[-1])
# Re-define the first item on the list and
example_xmas.pop(0)
example_xmas.insert(0, 'Mountain Bike')
# Re-define another item on the list and print all the list
example_xmas.pop(1)
example_xmas.insert(1, 'Unicycle')
print(example_xmas)
# Add an item to the list and print the list
example_xmas.append('Motorbike')
print(example_xmas)
# Remove an item from the list and print the list
example_xmas.remove('Motorbike')
print(example_xmas)
# Add two items to list and print the list
example_xmas.append('moon-cakes')
example_xmas.append('n log n')
print(example_xmas)
# example_xmas.append('iphone')
# example_xmas.append('money for icecream')
# print(example_xmas)
# done for now..