anonymous
  • anonymous
I'm having trouble, I'm trying to write a program that asks user to enter their last name then first and it keeps saying syntax error?
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 :)
SOLVED
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.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
what have you got so far?
anonymous
  • anonymous
well i was starting with print "Enter your last name" answer = raw_input () is this right so far?
anonymous
  • anonymous
Well, the raw input function takes a "prompt" argument, meaning that a better way to do that would be answer = raw_input('Enter your last name: ') What raw input does is it prints a prompt (whatever you put in quotes inside the parentheses) and returns the user's input after the prompt. So you can think of answer = raw_input('Enter your last name: ') as meaning: answer = what the user types after the prompt 'Enter your last name: ' But when I ran what you just posted: print "Enter your last name" answer = raw_input () I did NOT get a syntax error. Is there anything else in the file you were running that might've caused one? can you post the error message?

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Enter your last name Traceback (most recent call last): File "C:/Python31/homework2.py", line 2, in answer = raw_input () NameError: name 'raw_input' is not defined >>>
anonymous
  • anonymous
but i get it now it needs something written to define what raw_input is.
anonymous
  • anonymous
Thank You Very MUCH!
anonymous
  • anonymous
That error message is a Strange Thing. I'm pretty sure raw_input should always be defined. I'm not sure what's going on there.
anonymous
  • anonymous
If it persists, maybe try typing that line in the shell: answer = raw_input('Enter your last name: ') and just see what happens. I don't know if that will work and I have no particular reason to think it'll fix anything, but it's something I sometimes try as a sanity check to make sure I'm using a function correctly.
anonymous
  • anonymous
Enter your last name Traceback (most recent call last): File "C:/Python31/Homework1.py", line 2, in answer = raw_input("Enter your last name") NameError: name 'raw_input' is not defined >>>
anonymous
  • anonymous
It did it again.
anonymous
  • anonymous
Any Ideas?
anonymous
  • anonymous
I'd try creating a new document first. Then, if that didn't work, I'd type answer = raw_input('Enter your last name: ') directly in the shell, just to see if that worked. If it didn't, I'd try closing IDLE and restarting it. I'm also curious what happens when you type help('__builtin__') in the shell. raw_input is in the built in module--that module is supposed to be included in everything. If it's not getting included, I'm not at all sure why.
anonymous
  • anonymous
It did the same thing when i opened a new doc
anonymous
  • anonymous
What about when you type it in the shell?
anonymous
  • anonymous
The same thing happens when i type it into shell. When I type the help('__builtin__') it says no documentation was found under python?
anonymous
  • anonymous
no python documentation was found.
anonymous
  • anonymous
very weird. you've tried restarting IDLE?
anonymous
  • anonymous
yes and i had the same problem.
anonymous
  • anonymous
Gears, you're using Python 3. The course materials are written for Python 2. You'll have quite a few issues; I suggest you google on what those issues might be. I only know about the print statement; I've been careful to avoid Python 3 until a nice, sunny day on the beach. :)
anonymous
  • anonymous
Thank you so much I was not the person who installed the program this was my partner. This should fix many issues thank you.
anonymous
  • anonymous
Thanks Radly. I was becoming pretty confused.
anonymous
  • anonymous
Gears, you're using Python 3. The course materials are written for Python 2. You'll have quite a few issues; I suggest you google on what those issues might be. I only know about the print statement; I've been careful to avoid Python 3 until a nice, sunny day on the beach. :)
anonymous
  • anonymous
The path in the error trace gave it away. Luckily, he happened to be using a path that captured that clue. Otherwise, I'd have had no idea either.
anonymous
  • anonymous
Oh yeah! Error messages have become some of my main tools for debugging, but I didn't think to look at the path. The stuff I need is usually after that part. lesson learned.
chris
  • chris
hi Radly, don't want you to lose your reply if you've started. Server will be restarting in one minute! see you after the jump. Gears - sorry for polluting your question. Thanks
anonymous
  • anonymous
I'm also using python 3, trying to stay hip with the times. So far the two big differences I've run into are that print is now a function so you should use parentheses [ex.print("enter your name")] and "raw_input" is now just "input". Try it out! For a more complete list of the differences between python 2.x and 3 check out this page. http://docs.python.org/release/3.1.2/whatsnew/3.0.html

Looking for something else?

Not the answer you are looking for? Search for more explanations.