16. Using strings in lists and functions


#1



Question: why don't both version work?

n = ["Michael", "Lieberman"]
# Add your function here

def join_strings(words):
    result = ""
    for item in words:
        result = result + item
    return result

print join_strings(n)

-----------------
n = ["Michael", "Lieberman"]
# Add your function here

def join_strings(words):
    result = ""
    for item in words:
        result.append(item)
    return result

print join_strings(n)


#2

because .append() is a built in method for lists. You call it on a list, so far so good. But it is a method to append to lists, not strings


#3

OK cool thank you! Hope it doesn't bother anyone that I create posts for little questions like these?


#4

Actually, it is better to create a new topic like you did (even for small questions), a lot of small questions in one topic is actually very confusing. (who is replying to who)


#5

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