Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not Outputting
#3
Let's look from line 5.  If the conditional in line 5 evaluates to True we enter that conditional block.  Then if the conditional on line 6 evaluates to False the program ends.

What you want (presumably) is and, not a second nested if:
if (a + b) % 2 == 0 and (c + d) % 2 == 0:
    print("YES")
elif (a + b) % 2 != 0 and (c + d) % 2 != 0:
    print("YES")
else:
    print("NO")
Also it seems it could be simplified to this:
if (a + b) % 2 == (c + d) % 2:
    print("YES")
else:
    print("NO")
As both of the first two conditionals are asking if they evaluate to the same thing.
Reply


Messages In This Thread
Not Outputting - by goldtiger6 - Oct-13-2017, 06:42 PM
RE: Not Outputting - by Lux - Oct-13-2017, 07:23 PM
RE: Not Outputting - by Mekire - Oct-14-2017, 12:01 AM
RE: Not Outputting - by goldtiger6 - Oct-16-2017, 06:51 PM

Forum Jump:

User Panel Messages

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