Python Forum
Having problems using 'or' in a 'if' statement?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Having problems using 'or' in a 'if' statement?
#1
number1 = 5
number2 = 10

if number1 or number2 == 6:
    print("Successful !")
else:
    print("Failed !")
My problem is that the code isn't working as ı want.It writes "Successful" on the screen.But it shouldn't.Because the each side of the or isn't 6. So it's false.It should write "Failed !".

Help Me Plzzz ... Huh Huh Huh
Reply
#2
you mean
if number1 == 6 or number2 == 6:
or better yet
if 6 in (numerb1, number2):
Recommended Tutorials:
Reply
#3
Thanks !!! Heart Heart Heart
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems with if / else statement droid206 6 2,681 Apr-19-2020, 08:06 AM
Last Post: astral_travel
  problems with the If statement or is it the variables being used NickIgoe 2 2,099 Mar-22-2019, 06:34 AM
Last Post: NickIgoe

Forum Jump:

User Panel Messages

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