def argmax(x):
    """
    Returns the index of the largest element of the iterable `x`.

    If two or more elements equal the maximum value, the index of the first
    such element is returned.

    >>> argmax([1, 3, 2, 0])
    1

    >>> argmax(-abs(x) for x in range(-3, 4))
    3
    """
    argmax_ = None
    max_ = None
    for (nItem, item) in enumerate(x):
        if (argmax_ is None) or (item > max_):
            argmax_ = nItem
            max_ = item
    return argmax_