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

Hi, My first tryout: >>> def newlines(): … print() … print() … print() >>> question = “Which online Course you have signed up, dude?” >>> response = “Good Luck to you, dude!” >>> print (question), newlines(), input(), newlines(), print (response() #Result: Which online Course you have signed up, dude? “It is 6.00x, dude!” # My input. Good Luck to you, dude! (None, None, ‘”It is 6.00x”’, None, None) Can someone please tell me why Python is printing the last line and what is its meaning? Thanks in advance.

OpenStudy (anonymous):

I can't see. Here's what i tried. Which version of Python r u using ? #-----------PROGRAM def newlines(): print() print() print() question = "Which online Course you have signed up, dude?" response = "Good Luck to you, dude!" print(question), newlines(), input(), newlines(), print(response) #-----------END OF PROGRAM #-----------OUTPUT Which online Course you have signed up, dude? Nothing Good Luck to you, dude! #-----------END OF OUTPUT

OpenStudy (anonymous):

Hi Neeraj, Thanks for ur prompt reply. I have downloaded version 3.2.2. I tried again with what you have typed but i am still getting the last line : (None, None, "It is 6.00x dude.", None). Don't know if something is changed in the new version. So this question remains open for others, particularly those who have 3.2.2. Warm regards.

OpenStudy (anonymous):

Running each command on new line, like this will fix. print(question) newlines() input() newlines() print(response) I asked on SO, they told that this only happens when you run code in console as because the console will always print the result of last statement in this case it's a tuple "print(question), newlines(), input(), newlines(), print(response)". So the result of this line is (None, None, ‘”Input string”’, None, None) I was using Interactive shell that's why i was not getting that output.

OpenStudy (anonymous):

Sorry to bother you again but (1) tell me how to type the command on the next line? When I press [Enter] the interpreter immediately executes the first command.(2) what is SO ? (3) How to give a medal?

OpenStudy (anonymous):

1. Please use any python IDE or write code in file, then run it. There comes a IDE if you installed msi setup of python called IDLE http://upload.wikimedia.org/wikipedia/en/9/9b/Idle_gui.png. Search for it's shortcut or it'll be here C:\Program Files\Python\Lib\idlelib\idle.bat 2. SO is http://stackoverflow.com 3. You already did by clicking on 'Best answer'.

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!