---
id: 685cdfd1932d8ac6ad986813
title: Step 28
challengeType: 20
dashedName: step-28
---

# --description--

Within the `__str__` method, you'll show whether an email has been read or not. 

Conditional expressions allow you to assign a value based on a condition in a single line.

Here is an example:

```py
x = 10
y = 'Even' if x % 2 == 0 else 'Odd' # y will be Even
```

Within the method, before, use conditional expression to assign the string `Read` to a variable `status` if the email is read and `Unread` if it is not. 

# --hints--

You should have a `status` variable within the `__str__` method.

```js
({
    test: () => {
        assert(runPython(`_Node(_code).find_class("Email").find_function("__str__").has_variable("status")`));
    }
})
```

You should assign a conditional expression to the `status` variable.

```js
({
    test: () => {
        runPython(`
        import ast
        assert isinstance(_Node(_code).find_class("Email").find_function("__str__").find_variable("status").tree.value, ast.IfExp)`);
    }
})
```

Your conditional expression should evaluate to the string `Read` if the email is read and `Unread` if it is not.

```js
({
    test: () => {
        runPython(`
        if_exps = [
          "'Read' if self.read else 'Unread'",
          "'Read' if self.read == True else 'Unread'",
          "'Unread' if not self.read else 'Read'",
          "'Unread' if self.read == False else 'Read'"
        ]
        foo = _Node(_code).find_class("Email").find_function("__str__")
        assert any(foo.has_stmt(f"status = {if_exp}") for if_exp in if_exps)
        `);
    }
})
```

# --seed--

## --seed-contents--

```py
class Email:
    def __init__(self, sender, receiver, subject, body):
        self.sender = sender
        self.receiver = receiver
        self.subject = subject
        self.body = body
        self.read = False

    def mark_as_read(self):
        self.read = True

    def display_full_email(self):
        self.mark_as_read()
        print('\n--- Email ---')
        print(f'From: {self.sender.name}')
        print(f'To: {self.receiver.name}')
        print(f'Subject: {self.subject}')
        print(f'Body: {self.body}')
        print('------------\n')

    def __str__(self):
--fcc-editable-region--
        pass
--fcc-editable-region--

class User:
    def __init__(self, name):
        self.name = name
        self.inbox = Inbox()

    def send_email(self, receiver, subject, body):
        email = Email(sender=self, receiver=receiver, subject=subject, body=body)
        receiver.inbox.receive_email(email)

class Inbox:
    def __init__(self):
        self.emails = []
    
    def receive_email(self, email):
        self.emails.append(email)

```
