Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (Retired) Lists Redux Shopping List Take Three

benjamin siverly
benjamin siverly
3,430 Points

Attribute Error: "builtin_function_or_method" has no attribute 'split'... Error when only one item is added.

I keep getting an error message saying that new_stuff isn't splittable, but on the demo Kenneth's code works fine... Not sure what else to do on this...

shopping_list = []


def show_help():
    print("\nSeparate each item with a comma.")
    print("Type DONE to quit, SHOW to see the current list, and HELP to get this message.")


def show_list():
    count = 1
    for item in shopping_list:
        print("{}: {}".format(count, item))
        count += 1

print("Give me a list of things you want to shop for.")
show_help()

while True:
    new_stuff = input(">  ").lower
    if new_stuff == "done":
        print("\nHere's your list:")
        show_list()
        break
    elif new_stuff == "help":
        show_help()
        continue
    elif new_stuff == "show":
        show_list()
        continue
    else:
        new_list = new_stuff.split(", ")
        index = input("Add this at a certain spot? Press enter for the end of the list, "
                      "or give me a number. Currently {} items in the list.".format(
            len(shopping_list)))
        if index:
            spot = int(index) - 1
            for item in new_list:
                shopping_list.insert(spot,item.strip())
                spot += 1
        else:
            for item in new_list:
                shopping_list.append(item.strip())

1 Answer

Samuel Ferree
Samuel Ferree
31,721 Points

You're missing some parens* when you try to lowercase the input

def some_fn():
  return "Hi!"

some_fn() # This calls some_fn
some_fn # this is a variable that references the function, I can pass this around like any other variable. Like so

def call(fn):
  fn()

call(some_fn) # returns "Hi!"
benjamin siverly
benjamin siverly
3,430 Points

Got it! Didn't realize I needed parens at end of .lower

:)