What is wrong with this code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Boyyini
    New Member
    • Apr 2010
    • 5

    What is wrong with this code?

    I just started learning Python... 11 hours ago... And I tried to make an old-school dungeon game. So I made this program, but I get errors when I try to run it. I think its worth mentioning that I wrote the program while using Python 3.1 but I just changed to 2.6 because it seems to be used more.

    Code:
    print("Welcome to Boyyini's first program. \n This is my first attempt at making a program from scratch.")
    print("In this program I will be taking you through a text-based mini-adventure.")
    input("Press the enter key to continue.")
    print("First, I will ask you your name.")
    name = input("Please enter your name")
    print("Hello,", name,"What a nice name.")
    input("Press the enter key to continue.")
    gender = input("Are you a guy or girl?")
    print("Your a ", gender, "? Okay, that's cool.")
    age = input("How old are you?")
    print("Okay, I guess ",age, "is old enough to go...")
    print("Last question, do you have extensive liability insurence?")
    input("Ha ha ha, just kidding! ... Press Enter to start your adventure!")
    print("\n\nOkay! Now your at the entrance of the cave!")
    a = input("Do you want to Run In or Walk In?")
    if a == 'Run In':
        print("You burn a few calories.")
    if a == 'Walk In':
        print("You slowly walk in.")
    print("You survived the cave!")
    input("\n\nPress the enter key to exit.")
    The error I get is...
    Code:
    Traceback (most recent call last):
      File "C:\Documents and Settings\Boyyini\Desktop\Test1.py", line 3, in <module>
        input("Press the enter key to continue.")
      File "<string>", line 0
        
       ^
    SyntaxError: unexpected EOF while parsing
    How do I solve this? And are there any other things I should change?
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Substitute raw_input() for input() function calls.

    Comment

    • Avatar19
      New Member
      • Apr 2010
      • 43

      #3
      I looked at your code. Have a look at the changes and tell me what you think
      I added time delays and just made it generally friendlier to the user!!
      Code:
      import time
      print("Welcome to Boyyini's first program. \n This is my first attempt at making a program from scratch.")
      time.sleep(2)
      print("In this program I will be taking you through a text-based mini-adventure.")
      time.sleep(2)
      print("Press the enter key to continue.")
      A = ""
      if A == "":
          print("First, I will ask you your name.")
          name = raw_input("Please enter your name"" ")
      print "Hello,", name,"What a nice name."
      if A == "":
          time.sleep(1)
          print "Press the enter key to continue."
      gender = raw_input("Are you a guy or girl?"" ")
      print "Your a ", gender, "? Okay, that's cool."
      time.sleep(1)
      age = raw_input("How old are you?"" ")
      print "Okay, I guess ",age, "is old enough to go..."
      time.sleep(1)
      print("Last question, do you have extensive liability insurence?")
      time.sleep(2)
      print("Ha ha ha, just kidding! ... Press Enter to start your adventure!")
      B = raw_input()
      if B == "":
          print("\n\nOkay! Now your at the entrance of the cave!")
      a = raw_input("Do you want to Run In or Walk In?"" ")
      if a == 'Run In':
          print("You burn a few calories.")
      if a == 'Walk In':
          print("You slowly walk in.")
      time.sleep(1)
      print("You survived the cave!")
      time.sleep(1)
      print("\n\nPress the enter key to exit.")
      B = raw_input()
      if B == "":
          print " Come Again soon!!"
      Last edited by bvdet; Apr 10 '10, 05:10 PM. Reason: Add code tags

      Comment

      • bvdet
        Recognized Expert Specialist
        • Oct 2006
        • 2851

        #4
        Avatar19,

        Please use code tags when posting code. See posting guidelines here.

        BV - Moderator

        Comment

        • Avatar19
          New Member
          • Apr 2010
          • 43

          #5
          Apologies, will be more careful next time.
          Thanks!!

          Comment

          • Boyyini
            New Member
            • Apr 2010
            • 5

            #6
            Thanks for the help guys.

            Comment

            Working...