I have an input that takes two values
input1, input2 = input("Enter two types of pizza separate each with a space: ").split()
I notice that if I only enter one value, my program terminates and a ValueError: not enough values to unpack (expected 2, got 1)
is raised. Am I able to raise my own custom ValueError in this case and instead of terminating my program can I make it so it simply reprompts the user to enter it again? I think I can do this with a while
loop?
Here is my shot at it.
try:
input1, input2 = input("Enter two types of pizza separate each with a space: ").split()
if input1 = None or input2 = None:
raise ValueError("You must enter two types separate each with a comma")
except ValueError as err:
print("Ensure that you enter two types separate each with a comma")