Can someone tell me why i get None at the end please this has me stuck for ages

Chris Rebert clp2 at rebertia.com
Mon Feb 23 19:23:54 EST 2009


On Mon, Feb 23, 2009 at 11:22 AM, Gary Wood <woodygar at 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'
>     '''
>     word = [items]
>     for item in items:
>          print (item, end='')
>
>
> def main():
>     print(joinStrings(['very', 'hot','day']))
>     print(joinStrings(['this', 'is','it']))
>     print(joinStrings(['1', '2', '3', '4', '5']))
>
> main()

Reiterating myself from your previous thread which this is a duplicate of:

You're not supposed to *output* the strings in joinStrings() [i.e.
don't use print()!], you've supposed to *combine* them and *return*
the single combined string (it's nearly identical to how you summed
the numbers in the earlier exercise). The actual outputting of the
combined string is done by the calls to print() *outside* of
joinStrings(), in main().

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list