Dictionaries and Lists mix up?

Please refer to the link https://www.codecademy.com/courses/learn-python-3/informationals/python3-abruptly-goblins for my question below.

Can someone help to fix my code so that it correctly outputs the list of ‘gamer’ names who have ‘availability’ on the ‘game_night’ Thursday?

def available_on_night(gamers_list, day):
    can_go = ''
    for gamer in gamers_list:
        if day in gamer['availability']:
            can_go += gamer
    return(can_go)
            
attending_game_night = available_on_night(gamers, game_night)
print(attending_game_night)

My above code outputs the following message …

TypeError: can only concatenate str (not "dict") to str

I think can_go should be a list, not a string.
so
can_go = []

Also, you may need to do
can_go.append(gamer)
instead of
can_go += gamer
to add the contents of gamer to the that list.

1 Like

Yes thank you for helping me fix my code!