-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathList-examples.py
More file actions
41 lines (32 loc) · 802 Bytes
/
Copy pathList-examples.py
File metadata and controls
41 lines (32 loc) · 802 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'Phoenix1327'
classmates = ['Michael', 'Bob', 'Tracy']
print(classmates)
print(len(classmates))
print(classmates[-1])
classmates.insert(1, 'Jack')
print(classmates)
print(classmates.pop())
print(classmates)
print(classmates.pop(1))
print(classmates)
classmates[1] = 'Sarah'
print(classmates)
#exercise1
L = [
['Apple', 'Google', 'Microsoft'],
['Java', 'Python', 'Ruby', 'PHP'],
['Adam', 'Bart', 'Lisa']
]
print(L[0][0])
print(L[1][1])
print(L[2][2])
#exercise2
L1 = ['Hello', 'World', 18, 'Apple', None]
L2 = [s.lower() if isinstance(s, str) else s for s in L1]
L3 = [s.lower() for s in L1 if isinstance(s, str)]
#如果需要if else, if else写在for的前面
#如果只需要if, if写在for的后面
print(L2)
print(L3)