-3

I'm having trouble with getting my python code to work...I am making a story based game and i want to check if the user has inputted a correct class. My code:

ClassPicked = False

#Player Stats
Energy = 1
Health = 1

print("Hello, welcome to this text based game")

while ClassPicked == False:
    print("Please choose a class : Warrior or Mage")
    classType = input()

    #Failsafe to stop non roles to be selected
    if classType != "Paladin" "Warrior" or "Mage":
        print("You need to select a role")

    if classType == "Paladin" "Warrior" or "Mage":
        ClassPicked = True


print("You have selected", classType)

I need help as the while loop doesn't work, the user is just asked what class they would like to pick and no matter the input, the code will carry on

  • 2
    OP, next time please tell us exactly what the problem is. "Doesn't work" doesn't tell us anything useful. What error messages are you seeing? What's your traceback? If your code just isn't doing what you expect, tell us what inputs you're giving it, what you expect it to do, and what happens instead. See [ask]. – ChrisGPT was on strike Feb 06 '20 at 17:29

1 Answers1

0

or doesn't work the way you think it does. It only works between two entire expressions.

To check whether classType equals any of your things, you need to use a different strategy:

if classType not in ["Paladin", "Warrior", "Mage"]:
    print("select a role")
else:  # classType is one of those things exactly
    classPicked = True
Green Cloak Guy
  • 23,793
  • 4
  • 33
  • 53