0

#I want the While function to show only when the player has not written 'run' or 'Attack'. What can I do to correct this?

action = input("A goblin ambushes you, what do you do? ")

if action == "Run":
    print("You run and get away!")

if action == "Attack":
    print("You hit the Goblin, knocking it out!")

while action != "Attack" or "Run":
    action = input("That is not an action, what do you do? ")
Carcigenicate
  • 43,494
  • 9
  • 68
  • 117

1 Answers1

0

If I understand correctly, this should do the trick:

action = input("A goblin ambushes you, what do you do? ")
while action != "Attack" and action !="Run": 
    action = input("That is not an action, what do you do? ")

if action == "Run": 
    print("You run and get away!")
elif action == "Attack": 
    print("You hit the Goblin, knocking it out!")
Lennart Steinke
  • 584
  • 5
  • 11
  • Thank you so much. I am a huge noob in programming but this has helped me on the road to getting better and I appreciate it very much. – 86BuickRegal Jul 08 '20 at 02:10
  • You are very welcome. And we all started coding the same way, so don't worry. If this answers your questions, it would be really appreciated, if you could mark the question as answered by clicking the checkbox next to my reply :) – Lennart Steinke Jul 08 '20 at 10:27