1

I am starting from the VERY basics and I'm trying to create a simple madlibs-esque game where a user can import a verb, noun etc and the program will print a paragraph using these inputs, so far I have:

a = raw_input("Enter a verb")
input("\n\n")
b = raw_input("Enter a person")
input("\n\n")
c = raw_input("Enter a place")
input("\n\n")

and in a previous mini-program I used the code

input("\n\n")

Which made the program wait for the input of the enter key by the user, however now it will not wait for the user to enter anything and simply runs the entire program without delay.

I know this is a really basic problem but could somebody please point out why the program is not waiting for user input in this instance?

Thanks in advance!

I don't know what I have done to the Python interpreter, now it immediately closes after ANYTHING, even something I know is correct (because I copied it) such as:

def new_line():
    print

def three_lines():
    new_line()
    new_line()
    new_line()

print "First Line."
three_lines()
print "Second Line."

What is wrong with me?

2
  • Are you copying and pasting this code directly into an interpreter? If so, try doing it line by line or running the code from a file. Commented Oct 28, 2011 at 18:45
  • Hi, I was running it from a file, but it doesn't seem to like anything now. Commented Oct 28, 2011 at 18:54

2 Answers 2

1

If you do only :

a = raw_input("Enter a verb : ")
b = raw_input("Enter a person : ")
c = raw_input("Enter a place : ")

it should work.

As explained in python documentation, input() is only a sort of shortcut for eval(raw_input(prompt)), you don't need it in your case.

Sign up to request clarification or add additional context in comments.

6 Comments

I have broken something haha, it quits after every program you run without performing any of the actions, i.e. you open the program and it immediately closes the window :S
@GeorgeBurrows what about if you launch your script by calling the python executable with your_script.py when already beeing in a console window ?
python is actually saying invalid syntax, but then closing straight after when usually it stays open, how odd.
@GeorgeBurrows : paste the stacktrace in your question
Sorry but I am a novice and I haven't got to the part of the tutorial which says what a stacktrace is, what is the stacktrace?
|
0

I wouldn't think you would even need the second set of inputs. the raw_input with the prompt should accept the users input and move to the next line in the script after the user presses enter. the inputs with \n really shouldn't be necessary.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.