Python Forum
Even number code syntax error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Even number code syntax error
#1
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.
Larz60+ write May-02-2021, 06:32 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Fixed for you this time. Please use bbcode tags on future posts.
Reply
#2
eliminate all ':'
in addition, you need to use a simple algorithm rather than conditional statements.

x % 2 == 0 --> even
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation Invalid syntax error(Predict Ethereum Price) lulu43366 2 97 Sep-24-2021, 01:24 PM
Last Post: lulu43366
  Line 42 syntax error..Help!!1 patpython 4 277 Sep-01-2021, 03:22 PM
Last Post: deanhystad
  Unexplained Invalid syntax Error cybertooth 5 362 Aug-02-2021, 10:05 AM
Last Post: cybertooth
  I have a syntax error! rohes_kaugummi 3 533 Jun-23-2021, 05:24 PM
Last Post: deanhystad
  import module with syntax error Skaperen 7 609 Jun-22-2021, 10:38 AM
Last Post: Skaperen
Heart near "(": syntax error Maryan 3 744 Jun-21-2021, 08:05 AM
Last Post: ibreeden
Exclamation getting a syntax error and i don't know why ilikedofs 10 1,087 May-13-2021, 08:52 PM
Last Post: deanhystad
  error in your SQL syntax Xuli 10 1,006 May-02-2021, 12:27 PM
Last Post: Xuli
  Function syntax error Changosoyyo 2 691 Mar-07-2021, 10:42 PM
Last Post: Changosoyyo
  Syntax error on line 29 manwithjeans 3 817 Feb-27-2021, 08:28 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020