Hi.
I have a dictionary thus: (wraps)
p1hand =
{'b12':b12,'d12':d12,'d23':d23,'n12':n12,'n23':n23 ,'n34':n34,'p12':p12,'
p23':p23,'p34':p34,'p45':p45}
I set a variable called p1handlist so that I can print a list of the
keys to the screen:
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
This is for a simple text mode game I am writing and the output to the
screen is important because at times the list gets too big to print on
one line of the display.
Thanks!
John 2 1245
John wrote: Hi.
I have a dictionary thus: (wraps)
p1hand = {'b12':b12,'d12':d12,'d23':d23,'n12':n12,'n23':n23 ,'n34':n34,'p12':p12,' p23':p23,'p34':p34,'p45':p45}
I set a variable called p1handlist so that I can print a list of the keys to the screen:
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 can do something like this:
toPrint = ", ".join(p1handlist)
print toPrint
This is for a simple text mode game I am writing and the output to the screen is important because at times the list gets too big to print on one line of the display.
You might want to split the list first and then join the sublists.
--
Andres Rosado
Email: an*****@despammed.com
ICQ: 66750646
AIM: pantear
Homepage: http://andres980.tripod.com/
Every election is a sort of advance auction sale of stolen goods.
-- H.L. Mencken
In article <MP************************@news-server.columbus.rr.com>, Jo**@the.computer says... Hi.
I have a dictionary thus: (wraps)
p1hand = {'b12':b12,'d12':d12,'d23':d23,'n12':n12,'n23':n23 ,'n34':n34,'p12':p12,' p23':p23,'p34':p34,'p45':p45}
I set a variable called p1handlist so that I can print a list of the keys to the screen:
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
This is for a simple text mode game I am writing and the output to the screen is important because at times the list gets too big to print on one line of the display.
Thanks!
John
Robert & Andres,
Thanks so much for the help. As it turns out: print ', '.join(p1handlist)
does the trick! You have made me look like a genius! :)
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Martin Bless |
last post by:
Why can't we have an additional 'print' statement, that behaves
exactly like 'print' but doesn't insert that damn blank between two
arguments?
Could be called 'printn' or 'prin1' or 'prinn'...
|
by: middletree |
last post by:
I did a search in this forum, as well as at www.asp.faq.com, and MSDN, and
would like to know how to use ASP to build a report and create an .xls file
as a result.
I've seen lots of tutorials...
|
by: gk245 |
last post by:
I have this:
#include <stdio.h>
int main (void)
{
int number;
printf ("Enter number: ");
|
by: Lint Radley |
last post by:
Hi Everyone,
I've done several C# console applications now, and feel comfortable with
the language. Can anyone recommend a web site, book, etc which has
information on starting to develop full...
|
by: sam_cit |
last post by:
Hi,
I hear many say that it is better to convert address, i mean, type
cast into (void*) and print using %p identifier rather than %u, could
you let me know the specific reason behind it?
|
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted...
|
by: joeschnell |
last post by:
First week of the current trimester and we've taken a huge leap from writing little code snippets of loops and switches to writing an entire program, and expecting it to work!
I, nor anyone else in...
|
by: Dave |
last post by:
On my form I have combo boxes. These combo boxes, after updating
them, populate respective listboxes that are located below the combo
boxes on the same form. I am trying to use a "generate...
|
by: sniipe |
last post by:
Hi,
I have a problem with unicode string in Pylons templates(Mako). I will
print first char from my string encoded in UTF-8 and urllib.quote(),
for example string 'Łukasz':
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |