Tell us what’s happening:
I do not understand what is wrong with my code on step 8 of building the MediaCatalogue. The message I get back is that I should use an f-string in my except: block to print a message. Isn’t that what I am doing here?
Your code so far
class Movie:
def __init__(self, title, year, director, duration):
if not title.strip():
raise ValueError('Title cannot be empty')
if year < 1895:
raise ValueError('Year must be 1895 or later')
if not director.strip():
raise ValueError('Director cannot be empty')
if duration <= 0:
raise ValueError('Duration must be positive')
self.title = title
self.year = year
self.director = director
self.duration = duration
def __str__(self):
return f'{self.title} ({self.year}) - {self.duration} min, {self.director}'
# User Editable Region
try:
movie1 = Movie('The Matrix', 1999, 'The Wachowskis', 136)
except ValueError as e:
print(f"ValidationError: {e}")
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
Challenge Information:
Build a Media Catalogue - Step 8