17/18 Stuck

Hi everyone, stuck on this exercise, current code is

m = [1, 2, 3]
n = [4, 5, 6]

def join_lists(x, y):
result = x
for i in range(len(y)):
result += y(i)
return result

print join_lists(m, n)

Please help,
Thanks

it is a little too complicated you coded. follow the sample in the instruction of this task:

def join_lists(x,y): (indent)return x + y

yeah bro you did way too much here

can i ask why you don’t need to use a for loop on this?

1 Like

This is what I did and it worked, you need to read the instructions carefully:
def join_lists(x,y):
return x+y
join_lists()
print join_lists(m,n)

http://discuss.codecademy.com/t/17-18-using-two-lists-as-two-arguments-in-a-function/12683?u=js_

`` m = [1, 2, 3]
n = [4, 5, 6]

def join_lists(x, y):
joined = x + y
return joined

print join_lists(m, n)``

This is what I did. I don’t like calling return and creating the variable ‘joined’, in my case, all in one step. It’s probably not a big deal but it’s easier for me to see what’s happening in the code.

1 Like

Hello,

Personally, i don’t use varaiable just the return.

m = [1, 2, 3]
n = [4, 5, 6]

# Add your code here!
def join_lists(x, y):
    return x + y

print join_lists(m, n)
# You want this to print [1, 2, 3, 4, 5, 6]

Result :
[1, 2, 3, 4, 5, 6]
None

m = [1, 2, 3]
n = [4, 5, 6]

Add your code here!

def join_lists(x,y):
result =
for i in x:
result = x + y
return result
print join_lists(m, n)

I like to use the variable and making it a list. It makes your code more diverse. Say this was on a larger scale you would want to have the strings stored in to a list. Then when another function calls it, its already it the format needed to be stored into another list and so on so forth.