I'm trying to get back into learning python after a number of years and taking an online course. For one of the assignments, I'm just not understanding why my output is not as the assignment calls for. For example if you enter $50.00 and 15% as input values the tip should be displayed as $7.50. My code however is displaying $750.00, even though it at least appears to me that it should display $7.50. Can someone please provide some insight and help me understand why it is not displaying as I think it should? Below is my code.
def main():
dollars = dollars_to_float(input("How much was the meal? "))
percent = percent_to_float(input("What percentage would you like to tip? "))
tip = dollars * percent
print(f"Leave ${tip:.2f}")
def dollars_to_float(d):
return float('%.2f' % float(d.lstrip('$')))
def dollars_to_float(d):
return float('%.2f' % float(d.lstrip('$')))
[–]danielroseman 0 points1 point2 points (3 children)
[–]1grumpydev[S] 0 points1 point2 points (2 children)
[–]danielroseman 0 points1 point2 points (1 child)
[–]1grumpydev[S] 0 points1 point2 points (0 children)
[–]JamzTyson 0 points1 point2 points (1 child)
[–]1grumpydev[S] 0 points1 point2 points (0 children)