- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathresvers.py
More file actions
Latest commit
21 lines (16 loc) · 489 Bytes
/
Copy pathresvers.py
File metadata and controls
21 lines (16 loc) · 489 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
## 翻转列表内的元素
用到`list`的`[pop](https://docs.python.org/3.5/tutorial/datastructures.html)`和`append`方法。
```python
# -*- coding: utf -8 -*-
fromrandomimportrandrange
defrevers(seq, L=None):
whileseq:
ifLisNone:
L= []
L.append(seq.pop())
returnL
if__name__=="__main__":
lst= [randrange(100) for_inrange(10)]
print('This is original list\n', lst)
print('This is reversed list\n', revers(lst))
```