I'm always confused about ``TypeError`` and ``ValueError`` in python, but here I would use ``ValueError``, as the problem comes from the value of that variable and not from its type.