Safe Division
Completed
Read two integers on one line. Print a / b rounded to 3 places, or cannot divide by zero.
Input
One line: a b.
Output
One line.
Example
Input
10 4
Output
2.5
Editor
Python
Hints
Dividing by zero raises ZeroDivisionError.
Solution explanation
Sometimes asking forgiveness (try/except) is cleaner than checking first.
Show solution
a, b = map(int, input().split())
try:
print(round(a / b, 3))
except ZeroDivisionError:
print("cannot divide by zero")