Oops, try again. Your code looks a bit off. Check the console window for errors!


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/4/2?curriculum_id=4f89dab3d788890003000096


Oops, try again. Your code looks a bit off. Check the console window for errors!
Traceback (most recent call last):
File "python", line 12, in
File "python", line 7, in flatten
AttributeError: 'str' object has no attribute 'append'

can you check my code. help.


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



print flatten(n)


#2

The variable result should be an empty list not a string. Fix that, and everything will be good.


#3

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