Stringify a list

Stephen Hansen news at myNOSPAM.org
Wed May 16 12:01:03 CEST 2001


Hello,

    I'm not quite sure how to best solve your problem without "contortions"
if your list is a mix of numbers and strings. Its doable, but you'll need a
while/for loop, I think, and that qualifies as a contortion, I suspose. :)

    Now, if you change your logic such that a string representation of '2'
is inserted into the list, its easy.

Such as:

x = ['2', '6', 'A', '8', 'J']
print ", ".join(x)

HTH,

--Stephen

"Todd A. Jacobs" <nospam at codegnome.org> wrote in message
news:mailman.990003323.2806.python-list at python.org...
> I have a list object that contains card values (i.e. 2-10, J, Q, K, A),
> but I can't seem to print the list in such a way that it doesn't appear as
> follows:
>
> [2, 6, 'A', 8, 'J']
>
> I don't mind the commas, but how do I remove the quotes and brackets
> without going through contortions?
>
> --
> Todd A. Jacobs
> CodeGnome Consulting, LTD
>
>
>
>





More information about the Python-list mailing list