more while examples
This commit is contained in:
parent
d4f7e584b7
commit
de74c83f61
7
list.reverse.py
Normal file
7
list.reverse.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
i = 0
|
||||
lena = len(a)
|
||||
while i < lena // 2:
|
||||
a[i], a[lena -1 -i] = a[lena -1 -i], a[i]
|
||||
i += 1
|
||||
print(a)
|
6
negative.index.py
Normal file
6
negative.index.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
i = 0
|
||||
while i < len(a) // 2:
|
||||
a[i], a[-i -1] = a[-i -1], a[i]
|
||||
i += 1
|
||||
print(a)
|
6
negative.index.while.py
Normal file
6
negative.index.while.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
i = 0
|
||||
while i < len(a) // 2:
|
||||
a[i], a[-i - 1] = a[-i - 1], a[i]
|
||||
i += 1
|
||||
print(a)
|
Loading…
Reference in New Issue
Block a user