sp = int(input("the dp is $"))
print(sp)
while True: #make sure they only put number
try:
int(sp)
except ValueError:
try:
float(sp)
except ValueError:
print("This is not a number. Please put a valid price.")
print("Please enter a valid number")
#This is to ensure that the customer is entering a valid variable, not too high or low
if sp <=100: print("Your price is too low. Please enter a higher and valid price.")
if sp >=10000: print("Your price is too high. Please enter a lower and valid price")
当我尝试输入过高或过低的数字时,消息错误有效,但如果我输入字母,程序会显示错误。