Beginning programmer question - How to print a list in a different format
Eric @ Zomething
eric at zomething.com
Fri Feb 6 21:59:34 EST 2004
John wrote @ the computer:
> p1handlist = p1hand.keys()
> print p1handlist
>
> and the output looks like this:
>
> ['b12', 'd12', 'd23', 'n12', 'n23', 'n34', 'p12', 'p23', 'p34', 'p45']
>
> how can I make it so that the output looks more like this?:
>
> b12, d12, d23, n12, n23, n34, p12, p23, p34, p45
You're already there, but need to iterate over the keys instead of printing the list object p1handlist.
>>> for each in p1handlist:
print each
n12
n23
d23
b12
d12
>>> for each in p1hand.keys():
print each
n12
n23
d23
b12
d12
[I didn't load the full list]
Eric Pederson
More information about the Python-list
mailing list