On Mon, 23 Feb 2009 23:33:31 -0000, Gary Wood <woody...@sky.com> wrote:

'''exercise to complete and test this function'''
import string
def joinStrings(items):
    '''Join all the strings in stringList into one string,
    and return the result. For example:
    >>> print joinStrings(['very', 'hot', 'day'])
    'veryhotday'
    '''
    for i in items:
       return (''.join(items))

As I'm sure your teacher will point out, this is sub-optimal :-)
That for-loop isn't doing anything, because you always return
out of it at the first iteration.

I suspect that you're expected to concatenate the strings
together by hand and return the resulting string once you've
done them all.  Trying writing it that way.

PS: it helps a lot if what you say in the doc string matches
what you write in the rest of the code.  In this case you
call your input string "items", but then say "Join all the
strings in *stringList*..."

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to