Python code line not working in my game

So this line of code in my Python game doesn't work:

direction=raw_input("What would you like to do?\n")

      

The player is supposed to enter a command: North, South, East, West, Look, Search, Commands, or Inventory. This comes down to this:

Traceback (last call last): File "/ Users / khalilismail / Desktop / COMPUTING / Text games / DragonQuest.py", line 173, in direction = raw_input ("What would you like to do? \ N") EOFError: EOF while reading strings

Help

Here is a stack of code surrounding this: while play == on:

while place==town:

    direction=raw_input("What would you like to do?\n")

    if direction=="west":
        if "iron ore" and "wood" and "3 Gold Pieces" in items:
            print "The blacksmith greets you, and you tell him that you have the items and money he requires, you also give him the saw to make up for some of the difference, he then forges you a battleaxe and wishes you luck on the rest of your quest"
            items.remove ("saw")
            items.remove ("3 Gold Pieces")
            items.remove ("iron ore")
            items.remove ("wood")
            items.append ("battleaxe")

      

+3


source to share


1 answer


As pointed out in the comments, some editors do not support input (including Atom). Here are some options you can overcome:

  • Set the direction variable by hard coding when debugging (remember to remove it after debugging)
  • Change your editor (keep in mind that Sublime also has the same problem, but this one has a workaround - Sublime Text 2 tab for the console ; Notepad ++, however, does not have this problem when running code through the command line).


You can also try and remove the newline '\ n' from the raw_input string to see if it works.

0


source







All Articles