Python Practice › Loop Programs › Program 52
Numbers from 0 to 100 divisible by 5
Write a Python program to find the numbers from 0 to 100 divisible by 5.
Output
[0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]
Approach
- Keep numbers with
n % 5 == 0.
Solution
print([n for n in range(0, 101) if n % 5 == 0])Output
[0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]
Learn the concept
New to this topic? Read the lesson, then come back.