Nov-08-2022, 06:17 PM
Hi Team,
I am using below code getting error message.
But I want error properly line by line. I wan to print that error properly line by line.
I am using below code getting error message.
But I want error properly line by line. I wan to print that error properly line by line.
import traceback try: print(4/0) except ZeroDivisionError: print(traceback.format_exc())
Error:D:\Python\venv\Scripts\python.exe D:\Python\m12.py
Traceback (most recent call last):
File "D:\Python\m12.py", line 4, in <module>
print(4/0)
ZeroDivisionError: division by zero
Expected output:Output:File "D:\Python\m12.py"
line 4
print(4/0)
ZeroDivisionError: division by zero