Thread: Need Help

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Need Help


    Hey everyone, I decided it is the time for me to finally start learning python. This will be my first programming language, and I'm quite excited. I decided to make a small test, but I can't figure out why it doesn't work... If someone could show me whats wrong with it, I'll hopefully be good to go!

    Code:
    print ("You wake up and have no idea where you are.  You see a door")
    inpute = raw_input ("What would you like to do: ")
    def start ():
    if inpute == "sleep"
    sleep()
    elif inpute == "Door"
    door()
    
    
    # defining classes
    
    
    def sleep():
    print ("You go back to sleep and have peaceful dreams")
    
    def door():
    print ("You open the door, step outside, and fall into a mysterious void. It appears you have died. You should've just gone back to sleep")
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    39N 104.28W
    Posts
    158
    Rep Power
    3
    Your code shows no indents. Indentation is absolutely critical in Python.

    Furthermore, once your script finishes the last print, the window will close unless you put in something to make it pause (like raw_input("done")).
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    618
    Rep Power
    65
    Use something like this ...
    Code:
    # defining functions
    
    def sleep():
        print("You go back to sleep and have peaceful dreams.")
    
    def door():
        # use triple quotes for multiline text (relaxes indentation)
        print("""You open the door, step outside, and fall into a mysterious
    void. It appears you have died. You should've just gone back to sleep!""")
    
    print("You wake up and have no idea where you are.  You see a door")
    inpute = raw_input("What would you like to do (sleep or door): ")
    if inpute == "sleep":
        sleep()
    elif inpute == "door":
        door()
    
    # console wait ...
    raw_input("Press Enter to go on ...")
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25

IMN logo majestic logo threadwatch logo seochat tools logo