numbers = []
newNumbers = []
i = 0
while i < 100:
numbers.append(i)
i += 1
for i in numbers:
if numbers[i] % 5 == 0:
newNumbers.append(numbers[i])
if numbers[i] % 2 == 0:
newNumbers.append(numbers[i])
print(newNumbers)
[0, 0, 2, 4, 5, 6, 8, 10, 10, 12, 14, 15, 16, 18, 20, 20, 22, 24, 25, 26, 28, 30, 30, 32, 34, 35, 36, 38, 40, 40, 42, 44, 45, 46, 48, 50, 50, 52, 54, 55, 56, 58, 60, 60, 62, 64, 65, 66, 68, 70, 70, 72, 74, 75, 76, 78, 80, 80, 82, 84, 85, 86, 88, 90, 90, 92, 94, 95, 96, 98]
check = 0
for i in range(len(newNumbers)):
j = i-1
if newNumbers[i] == newNumbers[j]:
print("wrong on index " + str(j) + " and " + str(i))
check += 1
if check ==0:
print("All good :)")
wrong on index 0 and 1
wrong on index 7 and 8
wrong on index 14 and 15
wrong on index 21 and 22
wrong on index 28 and 29
wrong on index 35 and 36
wrong on index 42 and 43
wrong on index 49 and 50
wrong on index 56 and 57
wrong on index 63 and 64
numbers = []
newNumbers = []
i = 0
while i < 100:
numbers.append(i)
i += 1
for i in numbers:
if numbers[i] % 5 == 0:
newNumbers.append(numbers[i])
continue
if numbers[i] % 2 == 0:
newNumbers.append(numbers[i])
print(newNumbers)
[0, 2, 4, 5, 6, 8, 10, 12, 14, 15, 16, 18, 20, 22, 24, 25, 26, 28, 30, 32, 34, 35, 36, 38, 40, 42, 44, 45, 46, 48, 50, 52, 54, 55, 56, 58, 60, 62, 64, 65, 66, 68, 70, 72, 74, 75, 76, 78, 80, 82, 84, 85, 86, 88, 90, 92, 94, 95, 96, 98]
check = 0
for i in range(len(newNumbers)):
j = i-1
if newNumbers[i] == newNumbers[j]:
print("wrong on index " + str(j) + " and " + str(i))
check += 1
if check == 0:
print("All good :)")
All good :)
numbers = []
newNumbers = []
i = 0
while i < 100:
numbers.append(i)
i += 1
for i in numbers:
if numbers[i] % 5 == 0:
newNumbers.append(numbers[i])
elif numbers[i] % 2 == 0:
newNumbers.append(numbers[i])
print(newNumbers)
[0, 2, 4, 5, 6, 8, 10, 12, 14, 15, 16, 18, 20, 22, 24, 25, 26, 28, 30, 32, 34, 35, 36, 38, 40, 42, 44, 45, 46, 48, 50, 52, 54, 55, 56, 58, 60, 62, 64, 65, 66, 68, 70, 72, 74, 75, 76, 78, 80, 82, 84, 85, 86, 88, 90, 92, 94, 95, 96, 98]
check = 0
for i in range(len(newNumbers)):
j = i-1
if newNumbers[i] == newNumbers[j]:
print("wrong on index " + str(j) + " and " + str(i))
check += 1
if check == 0:
print("All good :)")
All good :)
numbers = []
newNumbers = []
i = 0
while i < 100:
numbers.append(i)
i += 1
for i in numbers:
if numbers[i] % 5 == 0 or numbers[i] % 2 == 0:
newNumbers.append(numbers[i])
print(newNumbers)
[0, 2, 4, 5, 6, 8, 10, 12, 14, 15, 16, 18, 20, 22, 24, 25, 26, 28, 30, 32, 34, 35, 36, 38, 40, 42, 44, 45, 46, 48, 50, 52, 54, 55, 56, 58, 60, 62, 64, 65, 66, 68, 70, 72, 74, 75, 76, 78, 80, 82, 84, 85, 86, 88, 90, 92, 94, 95, 96, 98]
check = 0
for i in range(len(newNumbers)):
j = i-1
if newNumbers[i] == newNumbers[j]:
print("wrong on index " + str(j) + " and " + str(i))
check += 1
if check == 0:
print("All good :)")
All good :)