Talk about the python built in variable reversed of seq
- 2020-06-07 04:41:10
- OfStack
1. Simple interpretation: invert 1 sequence object
Example 1:
def fun3():
x = [3,6,9]
for i in reversed(x):
print(i,end=',')
fun3()
Output:
""," nine,6,3,
Example 2:
>>> a = range(5)
>>> a
range(0, 5)
>>> list(a)
[0, 1, 2, 3, 4]
>>> a1 = reversed(a)
>>> list(a1)
[4, 3, 2, 1, 0]