-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlists.py
More file actions
38 lines (30 loc) · 651 Bytes
/
lists.py
File metadata and controls
38 lines (30 loc) · 651 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
# an empty list
empty = []
print(empty)
# list of string
str = ['Dave', 'Angela', 'Chloe', 'Charlotte']
print(str)
# list of number
nums = [36, 34, 6, 3]
print(nums)
# list of mixed item
mixed = ['Dave', 20, 'hello', 1.765]
print(mixed)
# indices and slicing
greetings = ['aloh', 'hello', 'hola']
print(greetings[0])
print(greetings[0:2])
print(greetings[1:])
print(greetings[1:])
# adding
brit_slang = ['cheerio', 'pip', 'smashing']
brit_slang.append('brilliant')
print(brit_slang)
# removing
brit_slang.remove('pip');
print brit_slang
del brit_slang[0]
print brit_slang
words = ['the', 'at', 'girl', 'song', 'bird']
del words[:2]
print words