# Using a list of lists in a function

#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

https://www.codecademy.com/courses/learn-python/lessons/lists-and-functions/exercises/using-a-list-of-lists-in-a-function

<In what way does your code behave incorrectly? Include ALL error messages.>

my code prints out

1
2
3
4
5
6
7
8
9
[]

error message says

flatten([[1, 2], [3, 4]]) returned [] instead of [1, 2, 3, 4]

<What do you expect to happen instead?>

```python

Replace this line with your code.

n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]
def flatten(lists):
results = []
for lists in n:
for item in lists:
print item
n.append(results)
return results

print flatten(n)

``<do not remove the three backticks above>``

#2

Instead of printing the item, append it to your list.

#3

So just delete the print line and thats it?

#4

Yes, and append the ITEM.

#5

n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]
def flatten(lists):
results = []
for lists in n:
for item in lists:
n.append(item)
return results

print flatten(n)

like so?

#6

Still canâ€™t tell. Did you read the new user articles, in particular the one about posting code samples?

#7

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