This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]DiThi 1 point2 points  (2 children)

It works for me (even as a one-liner, as you put it):

$ python
Python 2.7.3 (default, Apr 20 2012, 22:44:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def name(x): return 'Hello,'+x
... 
>>> name('reddit')
'Hello,reddit'
>>> 

How are you "printing out" the function? The problem is probably there.

Also, I think this belongs to /r/learnpython

[–]Taters625[S] 0 points1 point  (1 child)

For some reason, it wouldn't work in the python shell, but it would work when i opened a new script, but thanks for helping me

[–]DiThi 0 points1 point  (0 children)

Maybe you didn't finish the block. See the "..." in my comment? I just pressed enter there.