def get_state(walk_data, iteration=-1):
    """Pull walk_data values from a specific iteration.

    Routine to return slices of the walk_data dict at a given iteration #.
    This function provides a shortcut to 'smart' indexing of the dict.
    By default returns information on the most recent step

    **Inputs** :

        walk_data : `dict`
            Dictionary of all x and y locations and travel times

        iteration : `int`, optional
            Iteration number at which to slice the dictionary. Defaults
            to -1, i.e. the most recent step

    **Outputs** :

        xinds : `list`
            List containing equivalent of walk_data['xinds'][:][iteration]

        yinds : `list`
            List containing equivalent of walk_data['yinds'][:][iteration]

        times : `list`
            List containing equivalent of
            walk_data['travel_times'][:][iteration]

    """
    iteration = int(iteration)
    Np_tracer = len(walk_data['xinds'])  # Number of particles

    xinds = []
    yinds = []
    times = []
    iter_exceeds_warning = 0
    # Pull out the specified value
    for ii in list(range(Np_tracer)):
        try:
            xinds.append(walk_data['xinds'][ii][iteration])
            yinds.append(walk_data['yinds'][ii][iteration])
            times.append(walk_data['travel_times'][ii][iteration])
        except IndexError:
            # If target iter exceeds walk history, return last iter
            xinds.append(walk_data['xinds'][ii][-1])
            yinds.append(walk_data['yinds'][ii][-1])
            times.append(walk_data['travel_times'][ii][-1])
            iter_exceeds_warning += 1
    
    if iter_exceeds_warning > 0:
        print('Note: %s particles have not reached %s iterations' % \
              (iter_exceeds_warning, iteration))

    return xinds, yinds, times