from decimal import *
errors = "abcdffghijklmnopqrstuvwxyz?><:;\|{}[]"
purchase_price = Decimal(input("Please enter the price of your item"))
while purchase_price in errors:
print("Please enter the price of your item ex: 123.45")
break
else:
I'm having trouble checking if a character or characters in the errors var is being input.
When input is anything that is not a number
The Output is :
Traceback (most recent call last):
File "C:/Users/Chris/PycharmProjects/Tax Calculator/main.py", line 4, in <module>
purchase_price = Decimal(input("Please enter the price of your item"))
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]
If a character is there I would like to write a loop to give them another opportunity to to re-enter the price.
float(input("Please enter the price of your item"))It would cause an error if illegal char is entered