Eric Lin
Eric Lin

Reputation: 39

For loop does not print numbers that end with 0?

Suppose that 'i' is 90 and 90%10 = 0, it does not print 90.

numbers = [1,100]
for i in numbers:
    if i%10 == 0:
        print(i)

Output:

100

Should be: 10, 20 ... 100?

Upvotes: 0

Views: 154

Answers (1)

Stephen Gilardi
Stephen Gilardi

Reputation: 68

Your list only contains the values 1 and 100, not the range of numbers between 1 and 100. Use range instead.

numbers = range(1, 100)

Upvotes: 3

Related Questions