Using .append Instead


I want to know why I cant use .append to do this exercise. My code works when I use the result = result + words[item], but I get the error code below when I try to use the result.append(words[item]). Aren't the two lines doing basically the same thing? How can I use .append in this context.

AttributeError: 'str' object has no attribute 'append'

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

def join_strings(words):
    result = ""
    for item in range(len(words)):
       # result = result + words[item]
    return result

print join_strings(n)


Because we already have a list. Our job is to extract the words from that list and concatenate them into a single string object (no space characters).


what should be the exact code then.
i have tried so many codes but still confused in joining strings
can you please tell me how to join strings


'string" + "string" # 'stringstring'

Notice that the + operator when used on two strings acts as a string join operation.


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