Build an Email Simulator - Step 28

Tell us what’s happening:

Hi I don’t know why im not passing the test. I think my answer its fine. Maye I’m missing something.
Thanks in advance.

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):
        self.status = 'Read' if self.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 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0

Challenge Information:

Build an Email Simulator - Step 28

Hey, for this step you should create a variable, not an attribute.

Also, for the conditional expression, consider to use self.read truthiness instead of compare the value with True.

1 Like

Thanks. I understood I was creating a attribute not a variable as requested.Still, I dont fully understand why I can’t compare the value to True and I have to use the way you described.

Usually it’s preferable to avoid conditions like value == True or value == False because it does the same of value or not value and it’s less concise. In practice, it works the same way. In this case the test is strict and allows only one way to write the condition.

1 Like

Okey. Thank you so much!

1 Like