1. Post #1

    July 2012
    5 Posts
    Hey guys, I'd love some python help. Here's what I've got


    print """
    Hey! Looks like you've stumbled across my game. Well, good fucking luck.
    If you dont piss yourself, go get a cookie, you deserve it.
    Now, you walk into an alley, and at the end of the street you see a house.
    Now, it looks old, creepy, and honestly a bit scary. But you've been living
    on the street for the past 3 years so you're seriosuly considering going in to
    have a roof over your head. YOu notice the gate is creepy, creaky, not locked
    and..... half open! Do you want to go into what once was the front garden of this house?
    """

    input("""
    Yes? Or you could be a pussy and say no. Your choice
    [1] - Yes
    [2] - No
    """)

    if raw_input !=1:
    print "Well, you just got stabbed in the back multiple times by a stranger that was following you. Sorry dude. Re-run this app to play again."

    elif raw_input !=2:
    print "MUAHAHAHAHAHAHA. Good choice. Now, let me hand you over to my acquiantance. I think he wants to talk with you... :)"


    I'm trying to make a very simple text based game (very short also, wouldn't be long) just to practice. I assume you can figure out what I'm trying to do, but if not here goes. I want that long paragraph to pop up [working] then I want an input box asking if you want to go in or not [working] if you type 1 I want it to go to saw the "MUAHAHAHA" message, and if you type 2 I want it to go to the "Well," message. [not working] It doesn't seem to be differentiating the two by anything, no matter what I put in the input box, it always displays the first message, and when I delete it and the second message is the only one there, it always displays that. I don't know whats wrong. Help would be much appreciated, thanks!

    TL;DR - If someone could copy this code into their own interpreter/program, get it to work, and send me their code, I'd be able to compare it and see what I did wrong. Thanks.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Funny Funny x 1 (list)

  2. Post #2
    olavst's Avatar
    November 2011
    76 Posts
    This should work
    Code:
    print """
    Hey! Looks like you've stumbled across my game. Well, good fucking luck.
    If you dont piss yourself, go get a cookie, you deserve it.
    Now, you walk into an alley, and at the end of the street you see a house.
    Now, it looks old, creepy, and honestly a bit scary. But you've been living
    on the street for the past 3 years so you're seriosuly considering going in to
    have a roof over your head. You notice the gate is creepy, creaky, not locked
    and..... half open! Do you want to go into what once was the front garden of this house?
    """
    
    choice = input("""
    Yes? Or you could be a pussy and say no. Your choice
    [1] - Yes
    [2] - No
    """)
    
    if choice == 1:
        print "Well, you just got stabbed in the back multiple times by a stranger that was following you. Sorry dude. Re-run this app to play again."
    
    elif choice == 2:
        print "MUAHAHAHAHAHAHA. Good choice. Now, let me hand you over to my acquiantance. I think he wants to talk with you... :)"
    Reply With Quote Edit / Delete Reply Windows 7 Norway Show Events Agree Agree x 2 (list)

  3. Post #3

    July 2012
    5 Posts
    This should work
    Code:
    print """
    Hey! Looks like you've stumbled across my game. Well, good fucking luck.
    If you dont piss yourself, go get a cookie, you deserve it.
    Now, you walk into an alley, and at the end of the street you see a house.
    Now, it looks old, creepy, and honestly a bit scary. But you've been living
    on the street for the past 3 years so you're seriosuly considering going in to
    have a roof over your head. You notice the gate is creepy, creaky, not locked
    and..... half open! Do you want to go into what once was the front garden of this house?
    """
    
    choice = input("""
    Yes? Or you could be a pussy and say no. Your choice
    [1] - Yes
    [2] - No
    """)
    
    if choice == 1:
        print "Well, you just got stabbed in the back multiple times by a stranger that was following you. Sorry dude. Re-run this app to play again."
    
    elif choice == 2:
        print "MUAHAHAHAHAHAHA. Good choice. Now, let me hand you over to my acquiantance. I think he wants to talk with you... :)"
    you got the yes and no backwards, but it works!. Thanks dude

  4. Post #4
    Moussekateer's Avatar
    July 2011
    284 Posts
    I think it's important to note why your original script wasn't working (just in case you haven't realized yet).

    != means 'does not equal', while == means 'equal'. Also you were taking input and not assigning it to a variable, and then calling raw_input again (which would then again ask you to enter something).

  5. Post #5
    Project Lead, Internet Explorer for Linux
    lavacano's Avatar
    October 2008
    14,548 Posts
    Is this Python 2 or Python 3?

  6. Post #6
    Gnomical's Avatar
    September 2011
    1,541 Posts
    If you are using Python 2.x.x, do NOT use input. Use raw_input()!

    Code:
    print """
    Hey! Looks like you've stumbled across my game. Well, good fucking luck.
    If you dont piss yourself, go get a cookie, you deserve it.
    Now, you walk into an alley, and at the end of the street you see a house.
    Now, it looks old, creepy, and honestly a bit scary. But you've been living
    on the street for the past 3 years so you're seriosuly considering going in to
    have a roof over your head. YOu notice the gate is creepy, creaky, not locked
    and..... half open! Do you want to go into what once was the front garden of this house?
    """
    
    choice = raw_input("""
    Yes? Or you could be a pussy and say no. Your choice
    [1] - Yes
    [2] - No
    """)
    
    if choice == 2:
    print "Well, you just got stabbed in the back multiple times by a stranger that was following you. Sorry dude. Re-run this app to play again."
    
    elif choice ==1:
    print "MUAHAHAHAHAHAHA. Good choice. Now, let me hand you over to my acquiantance. I think he wants to talk with you... :)"
    (You said the yes and no was backwards for that guy, so I think it's this way? Either way you get it.