21. A list Num contains the following elements:3, 25, 13, 6, 35, 8, 14, 45Write a function to swap the content with the next value divisible by 5 so that the resultant list willlook like:25, 3, 13, 35, 6, 8, 45, 14
Answers
Answered by
3
Explanation:
Write a Python program to display the current date and time. ... 6. Write a Python program which accepts a sequence of comma-separated ... -1 -> [1, 5, 8, 3 ...
Answered by
1
Answer:
num=[3, 25, 13, 6, 35, 8, 14, 45]
for i in range(len(num) -1):
if num[i+1] % 5 == 0 :
num[i],num[i+1]=num[i+1],num[i]
print(num)
Explanation:
Similar questions