0

I have to whip up a text editor (spin off of Adventures into Zork) game for my summative project.

This is my decision for the first zone.

second = True
while second:
    firstLog = input(">")

This is where I am having problems, as when I input "Inside" or "In" the script gets terminated.

if firstLog = "Inside" or "In" or "Space Ship":
    print("There is a small " color.Bold + "console " + color.End + "in front of you.")
    print("You can " + color.Bold + "input " + color.End + "or" + color.Bold + "Exit" + color.End)
    second = False

Also if I enter anything else it terminates as well instead of printing this and restarting the loop.

else:
    "Not valid."
    second = True
Arnav
  • 5
  • 5
  • 5
    Show a [mcve] that demonstrates your problem. – Carcigenicate Mar 03 '18 at 20:32
  • 2
    Did you mean `if firstLog == "Inside" or firstLog == "In" or firstLog == "Space Ship":` ? –  Mar 03 '18 at 20:35
  • Also, your `if` condition does not do what you think it does. You can compare objects with `==`, not `=` and `or` chains multiple Boolean expressions. The expression `"Inside"` is just truthy, because it is a non-empty string – Graipher Mar 03 '18 at 20:36
  • @Tobias is right. `if firstLog == "Inside or "In"` will always be `True`, but you're using an assignment operator, anyway. – erip Mar 03 '18 at 20:36
  • Related: [How do I test multiple variables against a value?](https://stackoverflow.com/questions/15112125/how-do-i-test-multiple-variables-against-a-value) – Ilja Everilä Mar 03 '18 at 20:39

1 Answers1

4

Few things. The final else you are missing a print statement.

else:
    print("Not valid.")

The if firstLog should state the variable comparison again.

if firstLog == "Inside" or firstLog == "In" or firstLog == "Space Ship":

better yet, you could do something like this:

if firstLog.lower() in ["inside", "in", "space ship"]:
Aurelion
  • 168
  • 7