flag = 'y'
while flag == 'y':
try:
item_price = float(input('Enter item price: '))
item_quantity = float(input('Enter the item quantity: '))
if item_price > 0 and item_quantity > 0:
sub_total = item_quantity * item_price
total = sub_total + sub_total * 0.0825
print(f'Subtotal is ${sub_total}')
print(f'Total is ${round(total,2)}')
else:
print('Error: Enter a positive number for item price and quantity.')
except ValueError:
print('Error: Please enter a number!')
flag = input('Do you want to continue (y/n)?\n')
In this case I can enter a negative item price and only after entering quantity, the Error: Enter a positive number for item price and quantity.
is displayed. How do I display this error if the item price is negative ?