This:
elif ingredients == str(7) or str(8):
is different from:
elif ingredients == str(7) or ingredients == str(8):
and this:
elif ingredients == (str(7) or str(8)):
The second form is probably the logic you want to implement, which could also be written as:
elif any(ingredients == str(x) for x in (7, 8)):
or:
elif ingredients in {str(7), str(8)}:
EDIT
Also, perhaps you want to check the code as a whole:
Chef()
does not follow PEP8 naming conventions and does not return a int
(contrarily to your annotation).
rice_ingredients
contains a string which should contain a single number (based on the question you ask "How many ingredients: "
), looping through it will cause you to consider each character of the input separately, so that if you type 123
, ingredients
will be 1
, 2
and 3
at each iteration. Likely, what you want to do is convert rice_ingredients
to int
, e.g. rice_ingredients = input("How many ingredients: ")
to become rice_ingredients = int(input("How many ingredients: "))
- now that
rice_ingredients
is a int
you do not need to compare it against strings
exit()
will completely exit the interpreter, if you just want to quit the function use return
instead. Note that is is not needed to explicitly exit from the function at the end of it -- it will automatically do so
- the logic of the
if
-elif
-else
clause can be simplified further
A possible cleaned up code would look like:
def chef():
rice_ingredients = int(input("How many ingredients: "))
if rice_ingredients <= 6:
print("Professional")
elif rice_ingredients <= 8:
print("Well, can still be considered professional")
else:
print("Too much ingredients, unprofessional!")