![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Feb 2006
Location: USA,Michigan
Posts: 22
Rep Power: 0
![]() |
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
__________________
"Gee, Brain, what do you want to do tonight?" "The same thing we do every night, Pinky: Try to take over the world!" |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
As DaWei says, you can use a trailing comma:
python Syntax (Toggle Plain Text)
python Syntax (Toggle Plain Text)
python Syntax (Toggle Plain Text)
python Syntax (Toggle Plain Text)
|
|
|
|
|
|
#4 |
|
Newbie
Join Date: Feb 2006
Location: USA,Michigan
Posts: 22
Rep Power: 0
![]() |
Ok, thanks for the help. I fixed my problem using the second method Arevos sugested.
__________________
"Gee, Brain, what do you want to do tonight?" "The same thing we do every night, Pinky: Try to take over the world!" |
|
|
|
|
|
#5 |
|
Professional Programmer
|
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.
__________________
Amateurs built the ark Professionals built the Titanic |
|
|
|
|
|
#6 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Just to be correct, our esteemed Arevos' list comprehension is really a generator expression.
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
#7 |
|
Programmer
|
... 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 ![]() |
|
|
|
|
|
#8 |
|
Expert Programmer
|
Are you kidding? The current version of Python is 2.5, you know.
|
|
|
|
|
|
#9 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Unless your customer uses Python 2.3
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
#10 |
|
Programmer
Join Date: Apr 2005
Posts: 73
Rep Power: 4
![]() |
Heh! I've been pushing to get rid of 2.2 support from a certain project for a while -- the idioms 2.3 adds are so much nicer. Ah well... 2.5 will go stable sometime... as will 2.6... as will 2.7...
yrs obsolescent-compatibility-hurts-my-eyes-ly, -T. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Python] BlackJack | UnKnown X | Show Off Your Open Source Projects | 9 | Feb 20th, 2006 6:01 AM |
| First Python Programme: Fibonacci Finder | UnKnown X | Python | 2 | Dec 15th, 2005 6:19 PM |
| 2 new programs | HaCkeR | C | 30 | Nov 29th, 2005 7:14 AM |
| 2 problems with a script | glevine | Perl | 5 | Jul 20th, 2005 12:57 PM |
| ftplib help please! | disAbled | Python | 1 | Jun 30th, 2005 8:05 PM |