forked from dabeaz-course/practical-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise1.19.py
More file actions
53 lines (40 loc) · 762 Bytes
/
exercise1.19.py
File metadata and controls
53 lines (40 loc) · 762 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
43
44
45
46
47
48
49
50
51
52
# 1.19
symbols = 'HPQ,AAPL,IBM,MSFT,YHOO,DOA,GOOG'
symlist = symbols.split(',')
print(symlist)
symlist[2] = 'AIG'
print(symlist)
mysyms = []
mysyms.append('NOKIA')
symlist[-2:] = mysyms
print(symlist)
# 1.20
for s in symlist:
print(s)
# 1.21
print('NOKIA' in symlist)
print('DELL' not in symlist)
# 1.22
symlist.append('RHT')
symlist.insert(1,'AA')
symlist.append('YHOO')
print(symlist)
print(symlist.index('YHOO'))
print(symlist.count('YHOO'))
symlist.remove('YHOO')
print(symlist)
# 1.23
symlist.sort()
print(symlist)
symlist.sort(reverse=True)
print(symlist)
# 1.24
a = ', '.join(symlist)
print(a)
# 1.25
nums = [1,2,3,4,5]
items = ['spam', a, nums]
print(items)
print(items[1]) # string a
print(items[2][3]) #4
print(items[1][11:15]) # NOKI