Complete the code to raise a ValueError with a message.
if age < 0: raise ValueError([1])
We must pass a string message to ValueError to explain the problem.
Complete the code to catch a ValueError exception.
try: number = int(user_input) except [1]: print("Invalid number")
ValueError is raised when int() fails to convert a string to an integer.
Fix the error in raising a custom exception with a message.
class NegativeAgeError(Exception): pass if age < 0: raise NegativeAgeError([1])
The message must be a string, so it needs quotes.
Fill both blanks to create a dictionary of errors with messages longer than 10 characters.
errors = {field: msg for field, msg in error_dict.items() if len(msg) [1] [2]We want messages longer than 10 characters, so use > and 10.
Fill all three blanks to filter errors with keys starting with 'user' and messages containing 'invalid'.
filtered = {k: v for k, v in errors.items() if k.[1]('user') and 'invalid' [2] v and len(v) [3] 0}We check if key starts with 'user', 'invalid' is in the message, and message length is greater than 0.
