Build an Email Simulator - Step 15

Tell us what’s happening:

Step 15
Inbox class that takes self and an email object email as parameters. Within the method body, add the email to the emails list using the append method.

class Inbox:
def init(self):
self.emails = .append(emails)

def receive_email(self, email):
    self.email = email

You should append the email to self.emails.

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

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)


# User Editable Region

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

    def receive_email(self, email):
        self.email = email

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build an Email Simulator - Step 15

here you are appending to an empty list, make sure to double check what list you are asked to append what to

finally fix it

self.emails.append(email)

Tell us what’s happening:

Step 15
Your inbox needs a way to receive new emails. When someone sends an email to a user, it should be added to their inbox.

Add a method called receive_email to your Inbox class that takes self and an email object email as parameters. Within the method body, add the email to the emails list using the append method.

class Inbox:
def init(self):
self.emails = .append(emails)

def receive_email(self, email):
    self.email = email

You should append the email to sel

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

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)


# User Editable Region

class Inbox:
    def __init__(self):
        self.emails = emails.append(email)

    def receive_email(self, email):
        self.email = email

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build an Email Simulator - Step 15

Hi @dev_shinobi !

Here, you are asked to :

add the email to the emails list using the append method

but :

  1. You don’t add email to self.emails
  2. You don’t use append()

Hope this helped ! Enjoy coding ! :slight_smile:

its doesn’t help, how do I add email to self.emails

Wait, I just noticed that you have changed the initial code.

Previously, you defined self.emails as an empty list.

Next, you have to add the email to this list.

Why is this in the init() method? You were asked to do this in the receive_email() method.

Since you have changed the starting code where you were not asked to make changes, please reset this step and try again.

class Inbox:

def \__init_\_(self):

    self.emails = \[\]



def receive_email(self, email):

    self.email = email

finally solve it, Thanks

self.emails.append(email)

please do not create multiple topics for the same challenge, I have merged your two topics