Hey guys,

I need some help with Python (obviously).

I need python to insert a space.

I have:

name = raw_input('Enter your name? ') # prompt and read user's name

and that works, and it asks me for a name, and insert it, then i got:

print 'Hello ' + name

and it prints out

Hello,Cohen

I need to insert a space, how do i do it?

It's for a Australian School Competition - NCSS.

Thanks,

Cohen

print 'Hello ' + name

I think that's the problem. Try this script to output name with space

name = raw_input('name: ')
print 'hello,',name

That doesn't work :(

i just want to insert a space, is there a code i can put in?

Thanks,

Cohen

print 'Hello ' + name

Try this:

print "Hello,", name

The why:

If you use the code: "string1"+"string2"
You get the following: string1string2
However, if you use this: "string1","string2"
You get: "string1 string2" (notice the space)

Comments
Thanks for your Python help! It worked well!
This article has been dead for over six months. Start a new discussion instead.