anonymous
  • anonymous
I am working on problem set zeroi and It all works except how do you program a space between the question and the answer ?
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.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
Should be automatic. When I run my ps0.py the output after specifying both inputs has a space between first and last name.
anonymous
  • anonymous
not exactly, if he says print firstname + lastname it will be one word it should look print firstname, lastname (using a ",") if i get what you meant wrong, i apologize
anonymous
  • anonymous
Thanks nessman, thats what I was missing ,Also when it prints each name there is no space between the question and the answer !

Looking for something else?

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

More answers

anonymous
  • anonymous
i don't understand what you mean there, could you post your code and perhaps the output your having a problem with?
anonymous
  • anonymous
Oh. I see now. I was using print(first_name,last_name) so the space was there automatically.
anonymous
  • anonymous
string_1=raw_input("Enter your last name please" )
anonymous
  • anonymous
and after please there is no space betmeen the e and the first letter of the name
anonymous
  • anonymous
try string_1=raw_input("Enter your last name please\n" ) keeping the "\n" inside the quotes, this moves the cursor to the next line, there are a few other \commands that I remember seeing in our readings
anonymous
  • anonymous
print string_2 + string_1
anonymous
  • anonymous
nice let mne give that a shot
anonymous
  • anonymous
ok I had to go with + " " + to get the blank space inbetween names
anonymous
  • anonymous
that is odd, print string_2, string_1 gives me a space, its important to figure this out as when your working with anything that isn't a string you can't do that easily. eg: you can't number = 1 print number + " "apple" or at least in 2.7, or maybe I have a bigger problem how about your other problem?
anonymous
  • anonymous
yeah the \n puts the response on the next line
anonymous
  • anonymous
Thanks for the help
anonymous
  • anonymous
you could go print number + " " = apple
anonymous
  • anonymous
oops number + " " + apple
anonymous
  • anonymous
Weird, i get the error TypeError: unsupported operand type(s) for +: 'int' and 'str' its something that seriously gets in my way at times
anonymous
  • anonymous
hmmmm
anonymous
  • anonymous
These will all give you the same output (there are others too): print str(number) + ' some string' print number,'some string' print '%d some string'%number
anonymous
  • anonymous
what does "%d some string "% mean?, i have seen the other methods, but not the last
anonymous
  • anonymous
The %d basically says "I want to put an integer here". The %number at the end tells the interpreter to use the integer stored in the variable "number". I probably should have mentioned that this assumes "number" is an integer. You would use %f for a float, %s for a string, etc. You can also use '{0} some string'.format(number), which doesn't care about the variable type. For more info (and more string formatting options), check out: http://docs.python.org/library/stdtypes.html#string-formatting

Looking for something else?

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