18. Using a list of lists in a function


#1

Hi, HELP. HELP. HELP. I NEED HELP. YOU WILL BE THANKED WITH A FLOWER.

i really don't know what i'm doing wrong, i thought it was fine

n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]
# Add your function here
def flatten(lists):
    results = []
    for numbers in lists:
        for items in numbers:
            results.append(items)
        return results

print flatten(n)

.


#2

Aha! You're code is seriously awesome, but

you need to take this line one indent backwards. You want it to be inside of flatten, but not inside of any for each loop. :slight_smile:

BTW obsessed with your avi


#3

OMG THANKSSSSS for helping me. Here are the flowers :tulip: :sunflower: :blossom:
and THANK YOU VERY MUCH again!!!!


#4

No problem! You're doing great!


#5

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