def affiliation(n, C):
    """Return the affiliation of n for a given
    community C

    Parameters
    ----------
    n : object
    C : list of sets
      Community structure to search in

    Returns
    -------
    aff : list of ints
      Index of affiliation of n

    Examples
    --------
    >>> C = [set(['a','b']),set(['a'])]
    >>> nx.affiliation('a',C)
    [0,1]
    >>> nx.affiliation('b',C)
    [0]
    """
    aff = []
    i = 0
    for c in C:
        if n in c:
            aff.append(i)
        i += 1
    return aff