Build a Media Catalogue - Step 4

Tell us what’s happening:

Hey everyone! I’m stuck on
Step 4 of the ‘Build a Media Catalogue’ My code keeps failing with the error, ‘You should raise a ValueError with the message Title cannot be empty when title is either empty or contains whitespace only.’ I’ve tried a few things, but I can’t seem to get past it, could someone help me figure out what I’m missing? Thanks!

Your code so far


# User Editable Region

class Movie:
    def __init__(self, title, year, director, duration):
        if not title.strip():
            raise ValueError("Title cannot be empty.")
        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}"

movie1 = Movie('The Matrix', 1999, 'The Wachowskis', 136)
print(movie1)








# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0

Challenge Information:

Build a Media Catalogue - Step 4

You need to use the same punctuation as the instructions and error message (you have too much punctuation)

2 Likes