def find_text_color(hex_str):
    """Return correct text color, black or white,
    based on the background color.

    Parameters:
        hex_str (str): Hex color

    Returns:
        str: Output hex color for text
    """
    (r, g, b) = (hex_str[1:3], hex_str[3:5], hex_str[5:])
    color = "#ffffff"
    if 1 - (int(r, 16) * 0.299 + int(g, 16) * 0.587 + int(b, 16) * 0.114) / 255 < 0.5:
        color = '#000000'
    return color