Can someone tell me why i get None at the end please this has me stuck for ages
Rob Clewley
rob.clewley at gmail.com
Mon Feb 23 14:26:18 EST 2009
You get None b/c that's what's being returned from your join strings
function. Your function already prints out the result and doesn't
return the joined strings a your usage case expects.
So either return the joined strings from your function and don't print
them inside the function, or vice versa. Besides, can't you just use
print "".join(list_of_strings)
?
On Mon, Feb 23, 2009 at 2:22 PM, 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()
>
More information about the Python-list
mailing list