![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
I looked at the link, that note is simply a mistake in that case. It is correct if you line up a bunch of variables with commas directly after a print.
Another solution for the OP: def square(x):
return x * x
print "Value Square"
for i in range(1, 6):
print str(i) + " " + str(square(i))This would add a space for each comma used: def square(x):
return x * x
print "Value Square"
for i in range(1, 6):
print i, " ", square(i)
__________________
I looked it up on the Intergnats! Last edited by Dietrich; Jul 10th, 2007 at 1:38 PM. |
|
|
|
|
|
#12 |
|
Hobbyist Programmer
|
i like:
print "Value\tSquare"
for pair in [ (x, x*x for x in xrange(1, 6) ]:
print "%d\t%d"%(pair[0], [pair[1]) |
|
|
|
|
|
#13 | |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Quote:
__________________
I looked it up on the Intergnats! |
|
|
|
|
![]() |
| 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 |
| Beginers Python Tutorial | Beegie_B | Python | 15 | Jul 28th, 2006 11:43 AM |
| [tutorial] Python for programming beginners | coldDeath | Python | 30 | Dec 14th, 2005 11:35 AM |
| Convert Python script to C++ code | clanotheduck | Python | 17 | Sep 25th, 2005 8:55 AM |
| Advanced Python Tricks | Arevos | Python | 19 | Sep 24th, 2005 7:39 AM |
| Python - A Programmers Introduction | coldDeath | Python | 17 | Aug 19th, 2005 12:41 PM |