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

Create new Python Virtual environment

Create a new virtual environment  Python 3 allows you to manage separate package installations for different projects. It creates a “virtual” isolated Python installation. When you switch projects, you can

What are Large Language Models

LLM stands for Large Language Model in the context of artificial intelligence. It refers to a type of AI model designed to understand, generate, and manipulate human language on a

AI Roadmap using Python

Python is a great foundation for diving into AI! To take the next step in your AI learning journey, here’s a roadmap to guide you. 1. Strengthen Your Math Skills