![]() |
print problem
When I print something in python with a for loop it automatically skips a line after each print, like this:
0 1 2 3 4 5 How do I keep it from skipping a line so it outputs like this: 012345? thanks |
Investigate the comma. That may still not suit you, so look into formatted printing. There is a ton of information on it in the Python docs. You could, of course, simply concatenate prior to the print.
|
As DaWei says, you can use a trailing comma:
:
:
:
:
|
Ok, thanks for the help. I fixed my problem using the second method Arevos sugested.
|
In the future posting the code you're having trouble with will help you get more helpful posts much quicker. Glad you got it sorted out, though.
|
Just to be correct, our esteemed Arevos' list comprehension is really a generator expression.
|
... and generator expressions are new in python2.4
luckily, python2.4 will enter debian stable soon (if etch is on time), which removes my last excuse to stick with python2.3 ;) |
Are you kidding? The current version of Python is 2.5, you know.
|
Quote:
|
Quote:
yrs obsolescent-compatibility-hurts-my-eyes-ly, -T. |
| All times are GMT -5. The time now is 1:09 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC