---
id: 68af277560e009597dd861e8
title: Step 8
challengeType: 20
dashedName: step-8
---

# --description--

Now delete your `print(movie1)` line. Then, put your `movie1` assignment in a `try` block and create an `except` clause that catches `ValueError as e` and uses an f-string to print `Validation Error:` followed by a space and the error message.

Feel free to change the arguments passed to instantiate `movie1` to see the different error messages.

# --hints--

You should not have `print(movie1)` in your code.

```js
({
  test: () => runPython(`assert not _Node(_code).has_call("print(movie1)")`)
})
```

You should have a `try` block with `movie1 = Movie('The Matrix', 1999, 'The Wachowskis', 136)` inside it.

```js
({
    test: () => runPython(`assert _Node(_code).find_trys()[0].find_body().has_stmt("movie1 = Movie('The Matrix', 1999, 'The Wachowskis', 136)")`)
})
```

You should have an `except` clause that catches `ValueError as e`.

```js
({
    test: () => runPython(`assert _Node(_code).find_trys()[0].has_except("ValueError", "e")`)
})
```

You should use an f-string to print `Validation Error:` followed by a space and the error message within the `except` block.

```js
({
    test: () => runPython(`assert _Node(_code).find_trys()[0].find_except("ValueError", "e").has_call("print(f'Validation Error: {e}')")`)
})
```

# --seed--

## --seed-contents--

```py
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}'
--fcc-editable-region--
movie1 = Movie('The Matrix', 1999, 'The Wachowskis', 136)
print(movie1)
--fcc-editable-region--
```
