Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 19 Online
OpenStudy (anonymous):

Hi everyone. Im working on the first problem but whenever I input any program into the IDLE it will read and only follow the first line of code. Like Ill have x = raw_input('What is your date of birth? ') y = raw_input('What is your last name? ') print (y + x) It will ask the date of birth. I type it and press enter and it starts a new program as if the other lines of code weren't there. This seems to apply to all the prgms Im writing. Any help with this appreciated :)

OpenStudy (turingtest):

You should not be typing your code directly into the IDLE. Open a new window with CTRL+N, type your code there, then press F5 to run it.

OpenStudy (anonymous):

ctrl+n to open a new window. save the new window with a py (.py at the end of the name of the file) extension. f5 and save to run and see the results in the idle window. you can have multiple windows open at the same time. it's neat.

OpenStudy (anonymous):

That's because the REPL process Reads the line when you hit enter, Evaluates it, and Prints. The next time around it doesn't print x because you did not tell it to. If you type x it will return what was entered into the prompt previously as you are in the same environment. But to answer your question, what you want (are trying) to do is pause Evaluate until you are done entering in your code, but when you hit enter, you are telling REPL to Evaluate. There is nothing in your code to tell REPL that there is a continuation, like, for example, if you were entering in a loop and the line ends in :

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!