• Python - I need some help troubleshooting, I've had no luck :(
    5 replies, posted
  • 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.
  • 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... :)" [/CODE]
  • [QUOTE=olavst;36931272]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... :)" [/CODE][/QUOTE] you got the yes and no backwards, but it works!. Thanks dude
  • I think it's important to note [B]why[/B] 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).
  • 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... :)" [/code] (You said the yes and no was backwards for that guy, so I think it's this way? Either way you get it.