[solved]Getiting an error even though output is good


n = ["Michael", "Lieberman"]

def join_strings(words):
'results = " "
for i in words:
results = results + str(i)
return results

print join_strings(n)

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

Edit: put a space between the quotation marks of results

  1. List manipulations in functions:
    I am getting an error message although output is correct in console.
    n = [1, 2, 3, 4]

def list_extender(lst):
return n

print list_extender(n)

Error message says function returns [1,2,3,4,9,9] but output in console is [1,2,3,4,9]


@tootiedwyer: I belie this error is caused by the fact you're using the list n other than lst.
The argument lst holds the reference of the list n and you could use either of them but I believe the program tries several different inputs, without changing the values stored in the list n so that could be the issue here.

About the double nine entries: the only possible way it could happen is if the program that's compiling and executing your code is calling it again by itself so that could happen.


thanks for your reply g4be


No problem! Glad to help!