Python Forum
Even number code syntax error - 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: Even number code syntax error (/thread-33532.html)



Even number code syntax error - MrCeez - May-02-2021

I have just began my python journey
I am trying to write a code to check if vaue x y z are even numbers
This is my code
if x %2 == 0: or y %2 == 0: or z %2 == 0:
    print("This is an even number")
There is a syntax error and I don't know how to correct it.

I don't even know what it's doing but I understand (via textbook) that %2 ==0 checks if there is a remainder left and if so, then its not an even number.


RE: Even number code syntax error - Larz60+ - May-02-2021

eliminate all ':'
in addition, you need to use a simple algorithm rather than conditional statements.

x % 2 == 0 --> even