Python Forum
Return all Values which can divided by 9 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Return all Values which can divided by 9 (/thread-25031.html)



Return all Values which can divided by 9 - lastyle - Mar-16-2020

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


RE: Return all Values which can divided by 9 - scidam - Mar-16-2020

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.


RE: Return all Values which can divided by 9 - lastyle - Mar-16-2020

(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