from typing import Counter
import math


def shannon_entropy(data):
    """Calculates shannon entropy value

    Arguments:
        data {string} -- the string whose entropy must be calculated

    Returns:
        [float] -- value that represents the entropy value on the data {string}
    """
    p, lns = Counter(data), float(len(data))
    return -sum(count/lns * math.log(count/lns, 2) for count in p.values())