Python Forum

Full Version: Return all Values which can divided by 9
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all

i am searching for a funtion or simmilar solution that returns if a value can be divided by 9 without rest.

I was trying with Modulo operation but this didnt give me the correct result

for number in range(1, 3500):
    if(number % 9 != 0):
        print(number)
Anybody who might help me out with guiding to the correct Solution or giving a hint what i am searching for ?

Thanks in Advancee
I can give you a hint. If a number n is divisible by m without rest, n % m = 0.
Try the following examples
9 % 9
18 % 9
27 % 9
Hope this helps.
(Mar-16-2020, 12:10 PM)scidam Wrote: [ -> ]I can give you a hint. If a number n is divisible by m without rest, n % m = 0.
Try the following examples
9 % 9
18 % 9
27 % 9
Hope this helps.

Yep, thx a lot, didnt work directly but

for number in range(1, 3000):
    if(number % 9 == 0):
        print(number)
did the trick