-3

I'm trying to print numbers if they are not divisible by three or five and if they are divisible by three or five they should not be printed. This is my code:

i = int(input())
if (i == i/3) | (i == i/5):
    print('this number is divisible by 3 or 5')
else:
    print('i')

Im new to stackoverflow does not the properly how it works!!!!:(

user2653663
  • 2,818
  • 1
  • 18
  • 22
Marcus
  • 9
  • 2
  • You must include a [mre] in your question. A photograph of your monitor is not appropriate. – khelwood Oct 01 '19 at 10:05
  • Dear old [fizz buzz](https://en.wikipedia.org/wiki/Fizz_buzz) – Gsk Oct 01 '19 at 10:05
  • "This is my code". Can't see it buddy. – Mathieu Oct 01 '19 at 10:06
  • 2
    You have to have a look at python basics, maybe with a course from 0. `If` should not be uppercase, `:` missing, wrong quotations mark, no indentation... – Gsk Oct 01 '19 at 10:17
  • Possible duplicate of [How do you check whether a number is divisible by another number (Python)?](https://stackoverflow.com/questions/8002217/how-do-you-check-whether-a-number-is-divisible-by-another-number-python) – John Oct 01 '19 at 11:18

1 Answers1

0

If i = 5, then your if statement becomes

if (5 == 5/3) or (5 == 1):
    # do stuff

You're looking for the modulus %, which gives you the remainder of a division. Change the if statement to

if (i % 3 == 0) or (i % 5 == 0):

and it should work. For i = 5 this will give

if (2 == 0) or (0 == 0):
    # do stuff
user2653663
  • 2,818
  • 1
  • 18
  • 22