def sew_messages_and_reactions(messages, reactions):
 for message in messages:
  message['reactions'] = []
 converted_messages = {message['id']: message for message in messages}
 for reaction in reactions:
  converted_messages[reaction['message_id']]['reactions'].append(reaction)
 return list(converted_messages.values())

def sew_messages_and_reactions ( messages , reactions ) : for message in messages : message [ 'reactions' ] = [ ] converted_messages = { message [ 'id' ] : message for message in messages } for reaction in reactions : converted_messages [ reaction [ 'message_id' ] ] [ 'reactions' ] . append ( reaction ) return list ( converted_messages . values ( ) )
given a iterable of messages and reactions stitch reactions into messages .