-4

I can't seem to find the problem in code...

user_decision = ""
while not user_decision == "yes" or not user_decision == "no":
    user_decision = input("You want to Join?: Please answer (yes/no): ")
else:
    if user_decision == "yes":
        print("test")
    else:
        print("test")

Thanks....

alirehman
  • 5
  • 3
  • 8
    You want `and`, not `or`. – 001 Dec 04 '19 at 14:18
  • 4
    Also, `user_decision != "yes" ` is the same as `not user_decision == "yes"`, and might be easier to read – inspectorG4dget Dec 04 '19 at 14:18
  • you'd be better off checking this a different way: if you have a list of possible values, the "in" operator is handy instead of trying to get the grouping of a set of tests right: `while user_decision not in ('yes', 'no'):` – Mats Wichmann Dec 04 '19 at 14:29
  • I had solved it .... I just wanted to know what am I doing wrong in the above piece of code.... couldn't find it... so asked...Got it at the cost of 6 reps ... worth it... – alirehman Dec 04 '19 at 16:04

1 Answers1

0

I cleaned it up a bit:

user_decision = ""
while  (user_decision != "yes") and (user_decision != "no"):
    user_decision = input("You want to Join?: Please answer (yes/no): ")
    if user_decision == "yes":
        print("test yes")
    else:
        print("test not yes")
Ivan
  • 1,352
  • 2
  • 13
  • 31