0
Can the sum function in python add strings?
3 odpowiedzi
+ 3
We don't sum strings really, we concatenate them. The sum() function accepts an iterable and expected it to contain items of numerical data.
If you want to concatenate all the items of an iterable containing strings, you can use join() method of `str` class.
words = ( "sunshine", "daisies", "butter", "mellow", "turn", "this", "smart", "fit", "rat", "yellow" )
print( " ".join( words ) )
+ 1
Thanks, ipang. Question solved. (love the Harry Potter reference)
+ 1
Good job Conor Walsh 👍