I'm running into an issue with my Python program.
In fact, I have a sales price input which can contain a dollar sign and must respect the following constraints :
- It must be numeric
- The sales price must be at least $100, including dollars and cents
The problem I'm facing is : if the user inputs a sales price including a dollar sign, how to "ignore" it in order to determine if the input is numeric ? The same issue applies when it comes to a decimal point.
Also, note that :
- If the input is not a numeric entry, I would like it to prompt "price must be numeric".
- If the entry is less than $100, I would like it to prompt "Price must be at least $100".
This is what I have so far :
salesPrice= input("What is the sales price of the new phone? ")
if salesPrice[0]=="$":
val= int(salesPrice[1:])
if val < 100
print('Price must be at least $100')
else:
price=float(salesPrice[1:])
elif ValueError:
print('Price must be numeric')
else:
if salesPrice[0]!= '$':
if salesPrice[0:]< Min_price:
print('Price must be at least $100')
else:
price=float(salesPrice[0:])