Handling exceptions

Report a typo

Write a template that matches the names of the following errors:

  • ValueError
  • NameError
  • TypeError

After writing the template, take a string from the input, and compare it against the template. If there's a match (the result of match() is not None), print the first part of the error's name (Value, Name or Type). If there's no match, print None.

Write a program in Python 3
import re


# put your regex in the variable template
template = ""
string = input()
# compare the string and the template
___

Create a free account to access the full topic