Upon entering an input, say $50.00, I get an error that says ValueError: could not convert string to float: '$50.00'
. I already have dollars.removeprefix("$")
in line 10, the .removeprefix() method simply does nothing. What am I doing wrong? Full code below:
def main():
dollars = dollars_to_float(input("How much was the meal? "))
percent = percent_to_float(input("What percentage would you like to tip? "))
percent = percent / 100
tip = dollars * percent
print(f"Leave ${tip:.2f}")
def dollars_to_float(dollars):
dollars.removeprefix("$")
return float(dollars)
def percent_to_float(percent):
percent.removesuffix("%")
return float(percent)
main()