def avg(data):
    """Calculate the average of a list.

    >>> avg([1,2,3])
    2.0
    >>> avg([1,1,10])
    4.0
    >>> avg([3])
    3.0
    """

    if data:
        return (sum(data)) / float(len(data))
    return 0.0