I am trying to create a tip calculator like every other newbie and of course I ran in to a problem. Most of the code works fine, but I can't figure out how to take user input for the tip and incorporate it into the grand total.
This page was a good resource and told me that I need to point python in the direction to interpret the input as math used in the solution. I wasn't able to translate it in my head into my code though.
# Tip Calculator
import random
bill = input("How much was your bill? ")
x = float(bill)
tip10 = x * .10
tip15 = x * .15
tip20 = x * .20
tip10 = float(tip10)
tip15 = float(tip15)
tip20 = float(tip20)
total = x + tip10
total = x + tip15
total = x + tip20
print(f"If you would like to leave a 10%, the tip amount will be ${tip10}.")
print(f"If you would like to leave a 15%, the tip amount will be ${tip15}.")
print(f"If you would like to leave a 20%, the tip amount will be ${tip20}.")
input("How much tip would you like to leave? ")
print(f"Your total is ${total:.2f}.)
When I run this it is only giving me the tip20
result after asking how much tip to leave, which I finally figured out is because it is the last line of the totals.
How can I incorporate the user input into the total for the last line of code?