Newbie problem with lists
ncoghlan at email.com
Fri Feb 28 12:34:03 CET 2003
Jacob H wrote:
> for word in wordlist:
> wordlen = len(word)
> if (wordlen + charcount + 1) > colwidth:
> text = word + ' '
> charcount = wordlen + 1
> text = text + word + ' '
> charcount = charcount + (wordlen + 1)
between the two for loops - you currently seem to be missing the last line of text.
If your test string was < 116 characters, this would explain your problem.
Of course, if you have the option of playing with Python 2.3 then the program
from textwrap import wrap
lines = wrap(text, 58)
for line in lines:
# Do whatever it was you were doing in here
Nick Coghlan | Brisbane, Australia
ICQ#: 68854767 | ncoghlan AT email DOT com
Mobile: 0409 573 268 | http://oneofthesedays.not.there
"Let go your prejudices,
lest they limit your thoughts and actions."
More information about the Python-list