The Boredless Tourist, task 34

Hey everyone,

in the boredless tourist project task 34, when i try printing “add_attraction”, it shows me this

“<function add_attraction at 0x7f8843cc8950>”

instead of printing out the list.

here is my function:

def add_attraction(destination, attraction):

  try:

    destination_index = get_destination_index(destination)

    attractions_for_destination = attractions[destination_index].append(attraction)

  except SyntaxError:

    return 

add_attraction("Los Angeles, USA", ['Venice Beach', ['beach']])

i can’t find the bug in the code.
and thanks in advance!

That could be because you are printing it without the parentheses on the function call:

print(add_attraction)

This will print information about the function add_attraction, such as its type (function), its name, and where it is stored in memory. If you print it with parentheses:

print(add_attraction(parameter1, parameter2))

It should work.

I hope this helps!

1 Like

It’s also worth noting that the way it is written, that function has only side effects (altering the attractions_for_destination list) and doesn’t -> return <- anything to the caller. Even if you printed its return after passing the correct arguments you still wouldn’t get a value. Is that intentional?

1 Like