Obaid Obaid - 2 months ago 5
Python Question

printing list in python properly

So I have a list:

['x', 3, 'b']


And I want the output to be:

[x, 3, b]


How can I do this in python?

If I do
str(['x', 3, 'b'])
, I get one with quotes, but I don't want quotes.

Answer
mylist = ['x', 3, 'b']
print '[%s]' % ', '.join(map(str, mylist))
Comments