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
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
The comma between first, last already adds a space.
Thank you nicolas & jztein.
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)
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/
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.
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
Join our real-time social learning platform and learn together with your friends!