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

so i am trying to do problem set 0 and I've been reading through the wiki pages that the assignment lists to look through to try and get a better grasp on how to complete it. I think i have an idea as to how to complete it but i can't seem to figure how how to get the raw_input part to work please help. i type answer = raw_input("a sandwich") and it automatically writes a sandwich on the next line (with out >>> mind you) and when i to try write print ("You had " + answer + "! That sounds delicious") i get You had ! That sounds delicious.

OpenStudy (anonymous):

When you say ' answer = raw_input("a sandwich") ' It's asking for user input to a response to the phrase a sandwich. raw_input should be used for a variable that will change every time and should be a question so the user will know to provide an answer. For the next practice set you'll need to make a program that will work on any outstanding bank balance so it would be nice to use raw_input("What's the outstanding balance?") And it will print the phrase and then you type in a number to be used later in the script so it will therefore work with any outstanding balance. While you could still use your code as it is and type in 'a sandwich' as the response to your non question it'd be better to just replace the line with answer = "a sandwich" And because I'm a noob too, I just thought it might not work if you keep your code as is. If you really wanted to reply to 'a sandwich' you might have to make sure the raw_input is recognized as a string by using str(raw_input("a sandwich")) Hope this helps.

OpenStudy (rsmith6559):

raw_input() returns a string. You only need to convert numbers to use them for math.

OpenStudy (anonymous):

At bill thank you stop much that answer = raw_input("a sandwich") was actually my answer to question = "What did you have for lunch". i thought i had tried to write my answer to the question every way possible, but i guess not. Again thank you so much for the help man, now i have to just figure how to ask two questions and give to answers then have it reply with with both my answers.

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!