Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7643809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:32:17+00:00 2026-05-31T09:32:17+00:00

Topic 13: Question 2: Create a function that appends the name and email to

  • 0

Topic 13: Question 2: Create a function that appends the name and email to the end of a named file.

This is the code I wrote:

def addEmail(filename, name, email):
    f = open('filename', 'a') 

    f.write("%s\n" % name)
    f.write("%s\n" % email)
    f.close()

    return f

This is the output that I get on pyschools website:

Test Cases                                          Expected Result Returned Result Result
addEmail('email.txt', 'john', 'john@gmail.com').closed  True          True  

Private Test Cases                                   Passed            Failed   

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:32:18+00:00Added an answer on May 31, 2026 at 9:32 am

    Take a closer look at the sample output:

    >>> addEmail('emails.txt', 'Mary', 'mary@gmail.com') # content is 'Mary mary@gmail.com\n'
    >>> addEmail('emails.txt', 'John', 'john@gmail.com') # content is 'Mary mary@gmail.com\nJohn john@gmail.com\n'
    

    Note that in that output, the name and email are on the same line, separated by a space. You are putting the name and email on separate lines. Try changing your code to the following:

    f.write("%s %s\n" % (name, email))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a previous question that touched this topic ( Rails: how to get
this question is according to this topic: creating a huge dummy file in a
There are actually 2 question i want to cover in this topic. 1) Is
I asked a question about Garbage Collection in Java in this topic . But
I have read some topic regarding with my question but there code doesn't work
I have a question on the topic of memory management. When I create a
There is similar question on this topic I participated in it, but it doesn't
This question is sparked by a very frustrating problem that I find is a
I've seen this Topic : Creating an instance from a class name and written
I have read other questions on this topic but none that actually answers my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.