more while examples

This commit is contained in:
Mert Gör 🇹🇷 2023-05-20 13:31:25 +03:00
parent d4f7e584b7
commit de74c83f61
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
4 changed files with 21 additions and 0 deletions

7
list.reverse.py Normal file
View 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
View 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
View 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)

2
walrus.py Normal file
View File

@ -0,0 +1,2 @@
while (s := input('Bir yazı giriniz:')) != 'quit':
print(s[::-1])