# I have a problem with if statement (Python)

hello.
I’ve started learning python few days ago.
And i have a problem with if statement.

I coded like

and it doesn’t give any result.

I’ve tried with pycharm and visual studio code but both of them doesn’t give me a result

1 Like

Any i in range(1,1001) divided by 3 does not give an 0. I think it is a Maths problem.

It is not same as in C/C++, where 1/3 =0 and 2/3=0. Here int/int = float

1 Like

Then how can I get numbers that are multiples of 3 below 1000?

You need the modulo operation, not division. Division wouldn’t work even if it was cut to integers like in C, because e.g. `6 / 3` would give you 2, not zero.

The modulo operator in Python is `%`, so you could use:

``````for i in a:
if i % 3 == 0:
print(i)
``````

However, if you just need the numbers (and aren’t going to use the modulo for something more complex) it’d be much simpler to just use the `step` parameter for the `range` you’re iterating over:

``````for i in range(3, 1001, 3):
print(i)
``````

Note that I set the start value to 3 as well, if you start from 1 you get 1 plus multiples of three (1, 4, 7, …).