samedi 30 mai 2020

Can you see what i'm doing wrong

Hey guys I'm running into an issue with my Python program. Here's what I would like the code to do, the sales price input can contain a dollar sign, but it must be numeric; the sales price must be at least $100, including dollars and cents. (if the user includes a dollar sign, how will you “ignore” it to determine if the input is numeric? The same applies to a decimal point.) 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:])

Aucun commentaire:

Enregistrer un commentaire