Skip to content

Commit bbc6ed9

Browse files
committed
Updates 20170628.md
Auto commit by GitBook Editor
1 parent 0644711 commit bbc6ed9

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

20170628.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### 內建函數 item\(\)
22

3-
th`items()`function doesn't return key/value pairs in any specific order.
3+
th`items()`function doesn't return key/value pairs in any specific order.
44

55
```python
66
my_dict = {
@@ -11,7 +11,7 @@ my_dict = {
1111
print my_dict.items()
1212
```
1313

14-
\[\( 'Age', 20\), \( 'Name', 'Jiayi' \), \( 'height' , 155\) \]
14+
\[\( 'Age', 20\), \( 'Name', 'Jiayi' \), \( 'height' , 155\) \]
1515

1616
---
1717

@@ -32,9 +32,9 @@ print my_dict.keys()
3232
print my_dict.values()
3333
```
3434

35-
\['Name', 'Age', 'height' \]
35+
\['Name', 'Age', 'height' \]
3636

37-
\['Jiayi', 20, 155 \]
37+
\['Jiayi', 20, 155 \]
3838

3939
---
4040

@@ -51,11 +51,11 @@ for key in my_dict:
5151
print key, my_dict[key]
5252
```
5353

54-
Age 20
54+
Age 20
5555

5656
Name Jiayi
5757

58-
height 155
58+
height 155
5959

6060
```python
6161
for letter in 'JIAYI':
@@ -124,6 +124,26 @@ print to_five[::2]
124124
# print ['A', 'C', 'E']
125125
```
126126

127+
```python
128+
my_list = range(1, 11) # List of numbers 1 - 10
129+
print my_list[0::]
130+
print my_list[::2]
131+
```
132+
133+
\[1, 2, 3, 4, 5, 6, 7, 8, 9, 10\]
134+
135+
\[1, 3, 5, 7, 9\]
136+
137+
### Reversing a List
138+
139+
```python
140+
my_list = range(1, 11)
141+
backwards = my_list[::-1]
142+
print backwards
143+
```
144+
145+
\[10, 9, 8, 7, 6, 5, 4, 3, 2, 1\]
146+
127147

128148

129149

0 commit comments

Comments
 (0)