Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introducing Lists Using Lists Review Mutability

Why this code shows error??

I fully understand the code, I understand what this code is doing and I even gave the right answer, but I just wanted to try it on my own. I don't know why I'm getting a TypeError even when pasting the exact code. Can someone help me with this please? I'll be highly obliged! Thanks in advance!! Here's the Error: TypeError: argument of type 'builtin_function_or_method' is not iterable

boi
boi
14,242 Points

I tried this, and it gives me no error. Can you paste your code here? I need to see your code.

all_restaurants = [
    "Taco City",
    "Burgertown",
    "Tacovilla",
    "Hotdog station",
    "House of tacos",
    ]

def tacos_only(restaurants): 
    taco_joints = restaurants.copy()
    for taco_joint in taco_joints.copy():
        if "taco" not in taco_joint.lower:
            taco_joints.remove(taco_joint)
    return taco_joints  

dinner_options = tacos_only(all_restaurants)

print(dinner_options)

1 Answer

I think, I found my mistake. But thank you for your help. You made me to go through the code once again and I found that I typed .lower instead of lower(). Thank you so much, You did my help anyways!😂️