num = [3, 21, 5, 6, 14, 8, 14, 3]
num.reverse()
for i in range(len(num)-1):
if num[i] % 7 == 0:
num[i - 1], num[i] = num[i], num[i - 1]
num.reverse()
print("The required answer :", num)
solved I am trying to swap the two elements in the list, but after the first swap it keeps getting swapped as it fits the condition to be swapped