Oops, try again. join_strings(['x', 'y', 'z', 'a']) returned "['x', 'y', 'z', 'a']" instead of 'xyza'


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/3/5?curriculum_id=4f89dab3d788890003000096

Oops, try again. join_strings(['x', 'y', 'z', 'a']) returned "['x', 'y', 'z', 'a']" instead of 'xyza'

can you check my code?


n = ["Michael", "Lieberman"]
# Add your function here
def join_strings(words):
    result = ""
    for item in range(len(words)):
        result += str(words)
        return result
print join_strings(n)


#2

Have a closer look at:

range(len(words))

What are you thinking that evaluates to?

And this:

str(words)

What value does that give you?

If you can't figure them out then print them and see.


#3

how do you append word to result?


#4

Nevermind, I got it work. Thanks. Printing the lines really helped.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.