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)

commented: Thanks for your Python help! It worked well! +2

Try this:

print "Hello,", name

Thanks! that worked!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.