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

Assignment 0 (answer included): I'm interested in different variations of the answer. Below was the script I wrote: last = raw_input('What is your last name?') print last first = raw_input('What is your first name?') print first print 'Your name is ' + first,last One of the question I have is: Does it make a difference if you put a in between "first,last"... i.e: first, last instead of first,last

OpenStudy (anonymous):

It Does not make any difference, I guess the best think you can do it's try yourself, and see what's happen. It's more readable to write : first, last So usualy there is always space after a coma, but it is only conventional

OpenStudy (anonymous):

The comma between first, last already adds a space.

OpenStudy (anonymous):

Thank you nicolas & jztein.

OpenStudy (anonymous):

I usually use the str.format method ( http://docs.python.org/library/stdtypes.html#str.format), since you can type it exactly the way you want it to look for strings that are more complicated. In this case: print 'Your name is {0} {1}'.format(first,last)

OpenStudy (anonymous):

There is a website that has many different variations to each assignment. The link is: http://curiousreef.com/class/mit-opencourseware-600-introduction/lesson/1/retricen/1/

OpenStudy (anonymous):

This is my script, it is in the format the problem asked. last = raw_input('Enter your last name:\n**') first = raw_input('Enter your first name:\n**') print(first + '\n' + last) And to answer your question no, if you put the a space it is more visually pleasing but there is no difference in out. Generally you want clean readable code.

OpenStudy (anonymous):

My answer was a tad different. But yours seems simpler. question = "Enter your last name:" print question answer1 = raw_input () question2 = "Enter your first name:" print question2 answer2 = raw_input () print answer2 print answer1

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!