Nov-24-2022, 02:14 AM
(This post was last modified: Nov-24-2022, 07:11 AM by Yoriz.
Edit Reason: Added code tags
)
Hello, quite new to Python and would be happy for some help with an exercise I'm working on.
I'm trying to write a tip with $ and % signs and get answers without, then calculate tip as tip = dollars * percent.
The issue is that I'm getting the following error: "TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'".
My question is why do I get this? why dollars/percent are not defined as the answer for the questions?
Thank you!
I'm trying to write a tip with $ and % signs and get answers without, then calculate tip as tip = dollars * percent.
The issue is that I'm getting the following error: "TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'".
My question is why do I get this? why dollars/percent are not defined as the answer for the questions?
Thank you!
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):
dollars = print(float(d.lstrip("$")))
def percent_to_float(p):
percent = print(float(p.rstrip("%")))
main()
