What is "*="?


I have no idea what this " *= " right next to 'bill" thing is and how it works. Can't even find in google.

Replace this line with your code.

def tax(bill):
"""Adds 8% tax to a restaurant bill."""
bill *= 1.08
print ("With tax: %f" % bill)
return bill

def tip(bill):
"""Adds 15% tip to a restaurant bill."""
bill *= 1.15
print ("With tip: %f" % bill)
return bill


The *= python operator in full,

x *= 1

is the same as writing,

x = x * 1



Check this out: https://www.tutorialspoint.com/python/python_basic_operators.htm

This has all the operators for Python 2.7 and more! Here is the answer to your question:

*= Multiply AND It multiplies right operand with the left operand and assign the result to left operand c *= a is equivalent to c = c * a just as @bandit pointed it out!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.