Unsupported operand type(s) for *: NoneType and NoneType (Python)

Unsupported operand type(s) for *: NoneType and NoneType (Python)

In your function userinput(), you never return number, so python default to return None. Thus, when you pass x and y to multiply(), you are trying to do None * None, hence the error.

return number after the try/except structure in userinput()


If you also want to check for floats, you can do:

while True:
    number = input(Number: )
    try:
        return int(number)
    except ValueError:
        try:
            return float(number)
        except ValueError:
            print(NOPE...)

Unsupported operand type(s) for *: NoneType and NoneType (Python)

Leave a Reply

Your email address will not be published.