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

Albert Hopkins marduk at letterboxes.org
Mon Feb 23 14:27:25 EST 2009


On Mon, 2009-02-23 at 19:22 +0000, Gary Wood 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()

Your function, joinStrings() doesn't return a value. In Python a
function that doesn't return a value explicitly returns None by default.

So your print statements in main() will all print None.




More information about the Python-list mailing list