def extract_hourly_activity(grouped_dates):
    """
    This function counts the number of posts per hour from a pandas DataFrame
    that has been grouped according to date.

    Parameters:
        grouped_dates: a pandas DataFrame grouped according to date, with the
        time of posting in column 'time_created_local'.

    Returns:
        A dictionary with the hour as the key and the number of posts made on
        each date as the value.
    """
    # Set up a dictionary to hold the hourly activity
    hourly_activity = {}
    # Loop over each groups of posts for each date
    for i, d in grouped_dates:
        # Assign date (group key) and retrieve the number of posts made at each
        # hourand assign them to a dictionary.
        date, posts = i, d.time_created_local.apply(lambda x:
                                                    x.hour).\
                                                    value_counts().to_dict()
        # Loop over the dictionary of hours extracted from the dataframe; get
        # post keys (hours) and values (number of posts)
        for k, v in posts.items():
            # Try appending the post count to the dictionary, using the hour as
            # key
            try:
                hourly_activity[k].append(v)
            # If this raises a KeyError exception, create the new entry
            except KeyError:
                hourly_activity[k] = [v]

    # Return the dictionary with hourly activity
    return hourly_activity