-1
    ToppingsNumber = input("how many extra toppings do you want? (Max 3): ")
    try:
        int(ToppingsNumber)
        while ToppingsNumber > 3 or ToppingsNumber < 0:
            ToppingsNumber = input("enter a valid value!")
    except:
        while ToppingsNumber != type(int):
            print("enter an integer value")
            try:
                ToppingsNumber = (int(input))
                while ToppingsNumber > 3 or ToppingsNumber < 0:
                    ToppingsNumber = input("enter a valid value!")
            except:
                print("enter a valid value")

this bit of code starts outputting "enter a valid value" and "enter an integer" one after the other

khelwood
  • 55,782
  • 14
  • 81
  • 108
  • 1
    Check [Asking the user for input until they give a valid response](https://stackoverflow.com/q/23294658/3890632) – khelwood Apr 08 '21 at 08:03
  • `ToppingsNumber` will **always** be a `str`. – juanpa.arrivillaga Apr 08 '21 at 08:05
  • `ToppingsNumber != type(int)`—These things will never be equal.`int` is a type, so `type(int)` is `type`. Your `ToppingsNumber` is a string. It will never be equal to `type`. And `int(input)` makes no sense. `input` is a function. You can't convert it to an int. – khelwood Apr 08 '21 at 08:05
  • Use `isinstance(ToppingsNumber, int)` to check if it is an integer. Also in the first lool you never convert the string to an integer – mousetail Apr 08 '21 at 08:07

1 Answers1

0

The problem starts in your 3rd line, when you do

int(ToppingsNumber)

You have to assign the result of that conversion to the ToppingsNumber variable, that is

ToppingsNumber = int(ToppingsNumber)

Then you also have bellow

ToppingsNumber = int(input)

But you're missing the parenthesis in the call of input, which says to convert the function input to an integer instead of the value returned by it. Therefore, you should have

ToppingsNumber = int(input())

Moreover, and as mentioned in the comments, to check the type of a variable you should do

isinstance(ToppingsNumber, int)

or

type(ToppingsNumber) == int
gonced8
  • 9
  • 3