Reputation: 75
i want to print "(" in python
print "(" + var + ")"
but it says:
TypeError: coercing to Unicode: need string or buffer, NoneType found
can somebody help me? that cant be too hard... -.-
Upvotes: 3
Views: 29912
Reputation: 3119
Try this:
var = 'Hello World!'
print('(' + var + ')')
Also, your code works well on Python 2.7.4
, so long as you pre-define var
.
Upvotes: 0
Reputation: 4928
it appears that var
is None
in what you provided. Everything is correct, but var
does not contain a string.
Upvotes: 1