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

I'm working on Problem Set 0 and I'm trying to get the user's first and last names to print out in that order. I can get each name to print individually, but I'm assuming in the end, it wants to read something like this: Your first and last name (or name?) is Jimmy Stewart. Do I assign a variable for each name such as x=raw_input('What is your first name?') and y= raw_input (What is your last name?')? So it would read out as >>>print('Your first and last name is ' + x +y) and it would print out as Your first and last name is Jimmy Stewart

OpenStudy (anonymous):

Yes

OpenStudy (anonymous):

Now how would I go about writing that out. When I enter different variations of x=raw_input (What is your first name?') and y = raw_input ('What is your last name?'), I get back syntax errors and/or can't assign to operator

OpenStudy (anonymous):

what exactly did you type?

OpenStudy (anonymous):

>>>x = raw_input('What is your first name?') and y= raw_input('What is your last name?') which came out with SyntaxError: can't assign to operator So next I went ahead tried: >>>print('Your first name is ' + x) and ('Your last name is ' +y) which came out with Your name is Jimmy

OpenStudy (anonymous):

``` >>x = raw_input('What is your first name?') >>y = raw_input('What is your last name?') >>print('Your first name is ' + x) >>print('Your last name is ' +y) ```

OpenStudy (anonymous):

Ah let me try that, it seems so painfully obvious now

OpenStudy (anonymous):

Do you know what `and` is for?

OpenStudy (anonymous):

in this case I suppose I don't

OpenStudy (anonymous):

Ok so I followed your steps and great, it works! So that's the end of the problem?

OpenStudy (anonymous):

I don't know what the problem is

OpenStudy (anonymous):

Problem 1. Write a program that does the following in order: 1. Asks the user to enter his/her last name. 2. Asks the user to enter his/her first name. 3. Prints out the user’s first and last names in that order.

OpenStudy (anonymous):

Okay, so in your text editor you have to put the lines in order.

OpenStudy (anonymous):

``` lastname = raw_input('Enter last name:') firstname = raw_input('Enter first name:') print(firstname, lastname) ```

OpenStudy (anonymous):

Awesome, thank you so much! You've been invaluable.

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!