# Python challenge - Tip

In code challenges: Functions, number 2 is Tip. I’m able to get the 2.5 like it wants but not the 0. Below is my code and of course I get a syntax error when dividing by 0, but I can’t figure out how to get the answer it wants. When I divide total / percentage I get 0.4 and 0.

``````# Write your tip function here:
def tip(total, percentage):
return percentage / total
# Uncomment these function calls to test your tip function:
print(tip(10, 25))
# should print 2.5
print(tip(0, 100))
# should print 0.0
``````

This is what I get when I run that code:

2.5
Traceback (most recent call last):
File “script.py”, line 7, in
print(tip(0, 100))
File “script.py”, line 3, in tip
return percentage / total
ZeroDivisionError: division by zero

What am I doing wrong?

what’s 50% of 100?

I would review how percentages work in relation to the total (mathematically speaking)

@textsolver90830
Its not possible to divide a number zero. You are getting an error because its like you saying 100/0.