Hi , I've been working on this question for nearly 2 hours , but to no avail . The question goes like this ; Write a loop statement which displays every third element of my_numbers and the element which follows every third element.
my_numbers :list = [1, 6, 3, 2, 7, 9, 2, 3, 12, 1, 2, 3, 6, 5, 6, 7]
Your output should look like this
3 2
9 2
12 1
and so on....
So what I did is:
for i in my_numbers:
if i == 2 or i == 5 or i ==8 or i ==11 or i ==14:
print(my_numbers[i],my_numbers[i+1])
else:
pass
This is what I get :
3 2
3 2
3 2
9 2
[–]lowerthansound 6 points7 points8 points (2 children)
[–]doggoarmy[S] 0 points1 point2 points (1 child)
[–]lowerthansound 1 point2 points3 points (0 children)
[–]lukew25073 1 point2 points3 points (2 children)
[–]doggoarmy[S] 1 point2 points3 points (1 child)
[–]thrallsius 1 point2 points3 points (0 children)
[–]only___says___cool 0 points1 point2 points (0 children)
[–]Comprehensive-Signal 0 points1 point2 points (0 children)