def selectnpop(dic, lis, i=0):
    """If `dic[lis[i]]` exists, return it after popping `lis[i]`.

    Falls back on `dic[None]`.
    """
    try:
        selection = dic[lis[i]]
    except (IndexError, KeyError):
        return dic[None]
    lis.pop(i)
    return selection