appbrewery / 100-days-of-python

100 Days of Code - The Complete Python Pro Bootcamp
https://100daysofpython.dev/
1.66k stars 572 forks source link

Tip Calculator completed code;Day 2 Completed code; The conversion for rounding off to 2 decimal places not working #7

Open muditshamz opened 3 years ago

muditshamz commented 3 years ago

Below code is not working

final_amount = round(bill * (1 + tip / 100) / people, 2)
print(f"Each person should pay: ${final_amount}")
final_amount = round(bill * (1 + tip / 100) / people, 2)
final_contribution_eachHead = "{:.2f}".format(final_amount)
print("Every person will pay:$",final_contribution_eachHead)

Above code can further be optimised but looking at the level of exercise this detailed code is omitted of optimisation.

ThariqGIT commented 3 years ago

what is the error you are getting

ThariqGIT commented 3 years ago

/////////////////////works fine for me///////// Welcome to the tip calculator! What was the total bill? $12.78 How much tip would you like to give? 10, 12, or 15? 10 How many people to split the bill?3 Each person should pay: $4.69