def join_strings(words):
result = “”
for i in range(len(words)):
result += words(i)
return result
print join_strings(n)
What is wrong here? This gives an error and I don’t understand why? the solution to the exercise gives doesn’t’t use the range method so doesn’t help with the answer…?
Please post the most recent version of your code, so we can test it. Be sure to format the code so that we can view and copy its indentation. For advice on formatting posted code, see How to ask good questions (and get good answers).
n = ["Michael", "Lieberman"]
# Add your function here
def join_strings(words):
result = ""
for i in range(len(words)):
result += words[i]
return result
print join_strings(n)
Although now when I run it it seems to be OK! typical… maybe I hadn’t cleared the error…
Thanks for the link and the formatted code. However, the link went to a different exercise. The exercise you are doing is here: Using strings in lists in functions.