""" implementation of class Sack
"""
from random import randint


class Sack:
    """ A Sack with elements in no particular order.
    """

    def __init__(self) -> None:
        """ Create a new, empty Sack self.

        >>> s = Sack()
        """
        self._contents = []
        pass

    def add(self, obj) -> None:
        """ Add object obj to random position of Sack self.

        >>> s = Sack()
        >>> s.add("five")
        """
        self._contents.append(obj)
        pass

    def remove(self) -> object:
        """ Remove and return some random element of Sack self.

        Assume Sack self is not empty, other raises EmptySackException

        >>> s = Sack()
        >>> s.add(7)
        >>> s.remove()
        7
        """
        return self._contents.pop(randint(0, len(self._contents) - 1))
        pass

    def is_empty(self) -> bool:
        """ Return whether Sack self is empty.

        >>> s = Sack()
        >>> s.is_empty()
        True
        >>> s.add(5)
        >>> s.is_empty()
        False
        """
        return self._contents == []
        pass


if __name__ == "__main__":
    import doctest
    doctest.testmod()
    s = Sack()
    for i in range(20):
        s.add(i)
    while not s.is_empty():
        print(s.remove())


