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))
Output:
- Python tutorials
- Input and Output in Python
- f-strings in Python
- end and sep in Python
- Python QuickStart
- Variables in Python
- Data Types in Python
- Operators in Python
- Python program to compute net run rate
- Python program to get biggest number
- Python program to count the frequency of every element
- Python program of list and swap its content
- Python program to get max numbers
- Python program to generate patterns
- Python Program to Check ArmstrongÂ
- Python program to print multiplication table
- Python program for domestic electricity billÂ
- Python program to find maximum numberÂ
- Python program to check uppercase or lowercase letterÂ