>>> request = ('Enter your last name: ')
>>> response = raw_input()
>>> request2 = ('Enter your first name: ')
>>> response2 = raw_input()
>>> print (response2 + response)
Did I do this correctly?
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Sorry, that's Problem Set 0...
Looks like the right idea and it obviously worked. I might be reading your question wrong but have you typed all this into the *Python Shell* window?
If you do File --> new window then type:
request = 'Enter your last name: '
response = raw_input(request)
request2 = 'Enter your first name: '
print(resopnse2 + response)
Then press F5 or go to Run --> Run Module (it will ask you to save the program as something.py before it can be run)
Not the answer you are looking for? Search for more explanations.
A slight nitpick - the calls to request and request2 are unnecessary. You can pare down the code to simply,
reqfirst=raw_input('Enter your first name ')
reqlast=raw_input('Enter your last name ')
print reqfirst+' '+reqlast
(Note: If you don't care about the space at between the first and last name in the printline you can just put print reqfirst+reqlast.
Thanks for the help. I've been using IDLE to type my program in but I'm a little unclear on how to run it. I suppose I missed something. Do I run the program in IDLE?
First you open IDLE (I assume you have that part down). Now, what you just opened is the terminal (I think it's called - I'm new too!), and you can input basic commands there and get your answer. But to program something more you have to open a new window, which you can get by clicking file.
The new window (which looks like an empty notepad window) is where you type in the program. Type it in, hit F5, it'll ask you to save so save, and then it'll run the program in the terminal.
So I don't type the program in the shell, I type it in the new window? Lol, I'm a little lost.
What was I doing by typing it into the shell and not the window?
You were executing commands, but only one at a time. If you want to run an entire program at one time, you have to type it into the window. Say if I typed the above program into the window. Every time I wanted to do it, I'd have to write, firstreq=raw_input('What is your name? '), whereas if I had it saved in the window and executed the program, it would already have that line going through the shell.
are you in chat?
I just typed this into the new window:
firstrequest = ('Enter your last name: ')
firstresponse = raw_input()
secondrequest = ('Enter your first name: ')
secondresponse = raw_input()
print (secondresponse + firstresponse)
I saved it than ran it but nothing happened in the shell. It just returned a restart with >>>
You're not printing the firstrequest/secondrequest. See, you have firstrequest and secondrequest defined, but you're never calling them, and the raw_input has no string. So when you run the program, it's seeing that there's something called firstrequest and processes that, but isn't told to do anything with it, so it progresses onto firstresponse. Since there's nothing in firstresponse other than the raw_input command, you get the ability to input, but there's no prompt to do so.
That's why you're only getting >>>.
Also, like I said before, you can just put the firstrequest into the raw_input, like:
firstresponse = raw_input('Enter your last name ')
It'll still let you input, but this time you'll get a prompt to do so.