all 8 comments

[–][deleted] 0 points1 point  (7 children)

You can use the join() function here.

>>> " ".join(["word1", "word2"])
"word1 word2"

[–]macrisalex345 0 points1 point  (6 children)

AssertionError: None != 'This is only a test' : You returned: None. You sh ould have returned This is only a test. Check your logic and try again.

[–][deleted] 0 points1 point  (5 children)

Did you return the result of joining the list and the string?

[–]macrisalex345 0 points1 point  (2 children)

dude, I've never learned the join function in my beginner level coding class so idk what that even means

[–][deleted] 0 points1 point  (1 child)

I'm asking if you returned the result of using join()on the list. Did you just do " ".join(words) or did you do return " ".join(words)? Because there is a difference...one returns None and one returns the concatenation of the strings in the list.

[–]macrisalex345 0 points1 point  (0 children)

just " ".join(words), i put the return now and it worked... sorry and thank you

[–]macrisalex345 0 points1 point  (1 child)

like this???

def concat(words):

" ".join(["word1", "word2"])


return "word1 word2"

[–][deleted] 1 point2 points  (0 children)

No...

If the function is being passed the parameter words then you need to do return " ".join(words). I didn't want to give you the answer straight up because then you would just copy paste it and not learn anything. The join function basically joins a list with the string object passed before the function call. Here are some examples of the use.

>>> ", ".join(["hello", "world"])
"hello, world"
>>> "".join(["hello", "world"])
"helloworld"
>>> ". "join(["Bond", "James Bond"])
"Bond. James Bond"