0

I'm working hard on a small text-based RPG, and I ran into this issue:

In the beginning, I asked the player if they wanted to go left or right, and named that soldierdecisionone. After working through the entire story if the player chose left, I started on right. But when I said:

if soldierdecisionone=='Right' or soldierdecisionone=='right': input(...),

It said that everything after 'if soldierdecisionone=='Left'...' had a syntax error. If this doesn't make sense, I have here a link to a Google Doc with my code.

Thank you so much if you take the time to answer my confusing question, haha

https://docs.google.com/document/d/1qrnZ6cX2hZoXmKitJpWoIhcJfQF-3KVOJG4e1ftsUBk/edit?usp=sharing

3
  • Paste the code here Commented Jul 7, 2020 at 18:56
  • To save some space, string.upper() will convert the input into all upper case so you don't have to write or for each capitalization. Instead only saying if string.upper() == "UPPERCASE STRING": Commented Jul 7, 2020 at 18:59
  • Your google docs link has mangled the indentation of your code. Unfortunately, indentation matters in Python, so we have no way of understanding your code in its current form. Please edit your post to include the full code (with correct indentation) as well as the full error traceback. Commented Jul 7, 2020 at 19:02

1 Answer 1

1

Looking at your code, it seems that soldierdecisionone is not defined before you try to compare it to 'Right' or 'Left'.

Try adding solderdecisionone = '' above that line of code. You have similar errors with other variables like soldierattackorc

Be sure to define all of the variables before you use them.

Sign up to request clarification or add additional context in comments.

2 Comments

Hello! I don't know what you mean by defining it, I believe I already have. My code says if rpgclass=='S' or rpgclass=='s': soldierdecisionone=input('...'). Doesn't this define soldierdecisionone? Thank you for you answer
Defining a variable means you are telling the computer, "hey, this is a variable, so if i use this keyword again, know it's a variable." Python is special where you don't have a keyword, but you need to give a variable a value before you try and use it. In your example, you are comparing rpgclass to 'S', but rpgclass doesn't have a value. How are you supposed to compare something that doesn't have a value? You might also be getting confused with == vs =, where == is an equality operator and = is an assignment operator. tutorialspoint.com/python/python_basic_operators.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.