On Mon, Feb 9, 2009 at 4:53 PM, W W <sri...@gmail.com> wrote: > It's actually not the range but the print function. Print automatically > prints a newline. If you were to create a string of what print does: > > print 'foo' > > 'foo\n' > > However, adding a trailing comma will eliminate that. It will still add a > trailing space however. A better option would be like Marc suggests, > although you have to do concatenation: > > mystr += random.choice(pool) > > You do have some other options though. Create a list and join it with '': > > In [148]: x = ['a','b','c'] > > In [149]: ''.join(x) > Out[149]: 'abc' > > Create a list, convert it to tuple, and use string formatting: > > In [151]: '%s%s%s' % t > Out[151]: 'abc' > > Use sys.stdout.write instead: > > In [154]: for y in x: > .....: sys.stdout.write(y) > .....: > .....: > abc > > and a host of other options. The simplest is probably the concatenation > though ;) > HTH, > Wayne >
Thanks for the explanations, Wayne...the appending seems to do the trick, but I'm also going to keep these in mind for future reference. So many methods still left to learn. :) K
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor