Build a Media Catalogue - Step 7

Tell us what’s happening:

This seems straight forward to me and the test output is showing exactly the desired text. What is my error?

Your code so far

class Movie:

# User Editable Region

    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

# User Editable Region

    def __str__(self):
        return f'{self.title} ({self.year}) - {self.duration} min, {self.director}'

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

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 7

verify if duration is not greater than 0

What if duration is 0? This instruction is worded a little strangely

        if duration <= 0:
            raise ValueError('Duration must be positive')

It also does not pass. I also skipped to the next step of the workshop and copied the whole code but it doesn’t pass either.

This does pass the test for me.

Try to reset the step and try it again. Maybe something else changed accidentally

Not working for me either. Here is my code:

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}'

movie1 = Movie(‘The Matrix’, 1999, ‘The Wachowskis’, 136)

print(movie1)

hi @laynek, please create your own topic

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.