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

Working on problem set 0. Code works fine, but runs each command twice. Code - print ('Enter your last name') question2 = raw_input ('Enter your last name') print ('Enter your first name') question1 = ('Enter your first name') print question1 + question2 Output - Enter your last name Enter your last name jones Enter your first name Enter your first name smith smith jones It works, but why twice? Thank you.

OpenStudy (anonymous):

Got it - see below. question1 = raw_input('last name') question2 = raw_input('first name') print question2 + question1

OpenStudy (e.mccormick):

Or for a space between: print question2 + " " + question2

OpenStudy (e.mccormick):

Well, 2 then 1... but the " " adds the space.

OpenStudy (anonymous):

or just ``` print question2, question1 ```

OpenStudy (anonymous):

Make sure you read the readings for the course and practice the examples.

OpenStudy (e.mccormick):

Or read the reading and practice the practicals.... =P If you don't have the course book, there is an open alternative that is a pretty good substitute.

OpenStudy (anonymous):

Thank you all. Working on the readings and do have alternative books.

OpenStudy (anonymous):

Just question. Do you guys think it's alright if I used xs and ys instead of question1 and question2? Here's what it all looks like. >>>x=raw_input('Enter your date of birth:') Enter your date of birth: 01/01/01 >>>y=raw_input('Enter your last name:') Enter your last name: Smith >>>print y, x Smith 01/01/01 Is this when they were looking for or am I completely off?

OpenStudy (anonymous):

You can name your variables whatever you want. You might want to get in the habit of giving your variables meaningful names - it will make your code easier to read.

OpenStudy (anonymous):

Okay! Thank you so much! You're great help!

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!