def last_element(iter):  # pylint: disable=W0622
    """
    Returns the last element of sequence assuming they
    were generated by an iterator or a generator.

    @param      iter        iterator or generator
    @return                 element

    .. runpython::
        :showcode:

        from ensae_projects.hackathon.image_helper import last_element

        def gen():
            for i in range(10):
                yield "A%d" % i

        print(last_element(gen()))
    """
    el = None
    for el in iter:
        pass
    return el