-1

I'm having problems with a code I've been writing for about an hour or two, it was working and I was near to completing the game I was making, when it decided that I've done it wrong. I don't understand, I didn't edit this little bit of text, yet now, it has decided that it's wrong after having worked fine earlier! I'm a newbie to Python, but it's almost as if the text has changed it's mind about whether it wants to work or now.

room2 = input("> ")
if room2 == "2":

Okay so basically the code that I was doing was:

room = input ("> ")
if room = "1":
  print("blahblah")

What I'm going for is a text adventure.

13
  • 3
    What error message are you getting? Commented Jun 17, 2013 at 1:35
  • which version of python are you using? Commented Jun 17, 2013 at 1:37
  • Invalid syntax, this is for pretty much every part of that same code. Commented Jun 17, 2013 at 1:38
  • Turn on the 'show white-space' feature of your editor and see if there is any inconsistent indentation. Commented Jun 17, 2013 at 1:39
  • I am using python 3.3.2 Commented Jun 17, 2013 at 1:39

3 Answers 3

2
room = input ("> ")
if room == "1":  # You forgot one =
  print("blahblah")
Sign up to request clarification or add additional context in comments.

Comments

1

Yes, you've forgotten a single = here. Remember that = is assignment and == the equality check in many languages.

if room == "1":
  print("blahblah")

Don't beat yourself up about it though, it happens. Just learn to check again.

Comments

1
room = input ("> ")
if room == "1":
  print("blahblah")

= -> ==

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.