Need help with 17/18 List and functions


#1


Oops, try again. join_lists([1, 2], [3, 4]) returned None, did you remember to return the result?

Its supposed to concatenate each lists one after the other

m = [1,2,3]  
n = [4,5,6]  
o = [7,8,9]
def join_lists(x, y):
    def myFun(*x):  
        s = []
        for i in x:
            s += i
        return s

print myFun(m,n,o)   # [1, 2, 3, 4, 5, 6, 7, 8, 9]


#2

>>> m = [1,2,3]
>>> n = [4,5,6]
>>> o = [7,8,9]
>>> def join_lists(x, y):
    def myFun(*x):
        s = []
        for i in x:
            s += i
        return s

>>> print (myFun(m,n,o))
Traceback (most recent call last):
  File "<pyshell#217>", line 1, in <module>
    print (myFun(m,n,o))
NameError: name 'myFun' is not defined
>>>

#3

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