Below is a program to create a list of numbers and swap the content with the next value divisible by 5.

n=int(input("Enter the number of list : "))
l=[]
for i in range(n):
    m=int(input("Enter the number "+str(i+1)+" : "))
    l.append(m)

for i in range (len(l)):
   if i%5==0 :
      l[i],l[i+1]=l[i+1],l[i]
print("list after swaped :" +str(l))
Python program of list and swap its content

Output:

Python program of list and swap its content

Explore More

Input and Output in Python

Understanding input and output operations is fundamental to Python programming. With the print() function, you can display output in various formats, when the input() function/method enables interaction with users by gathering

end and sep in Python

end in Python The end is a parameter in Python’s built-in print() function/method that controls what character(s) are printed at the end of the printed text.  Syntax : Output :

f-strings in Python

Python offers a powerful feature called f-strings (formatted string literals) to simplify string formatting and interpolation. f-strings is introduced in Python 3.6 it provides a concise and intuitive way to embed expressions and variables