Build an Email Simulator - Step 28

Tell us what’s happening:

Hello.

I’ve faced a problem in this step where it is asking me to: “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.”

Here’s a sample of the specific part of the code:

def __str__(self):
    status = 'Read' if read == True else 'Unread'

If you can, please explain what is the problem and why it won’t pass.

Your code so far

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


# User Editable Region

    def __str__(self):
        status = 'Read' if read == True else 'Unread'

# User 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)

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Mobile Safari/537.36

Challenge Information:

Build an Email Simulator - Step 28

what is read? do you have a read variable?