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 8777163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:13:15+00:00 2026-06-13T19:13:15+00:00

I am making a program that lets you edit, or read a text document

  • 0

I am making a program that lets you edit, or read a text document in python, and I’m not finished yet, and I’m stuck on the reading part. I want it to print only one line, and I’m drawing a blank on how to do so. The read part is in “def read():”

def menu():
    print("What would you like to do?")
    print("\n(1) Write new text")
    print("(2) Read line 3")
    choice = float(input())
    if choice == 1:
        write()
    elif choice == 2:
        read()

def read():
    with open('test.txt', 'r') as read:
        print()

def write():
    print("\nType the full name of the file you wish to write in.")
    file1 = input().strip()
    with open(file1, "a") as add:
        print("What do you want to write?")
        text = input()
        add.write("\n"+ text)

menu()
  • 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-06-13T19:13:15+00:00Added an answer on June 13, 2026 at 7:13 pm
    def read():
        with open('test.txt', 'r') as f:
            for line in f:
                print(line)
    

    Edit:

    def read():
        with open('test.txt', 'r') as f:
            lines = f.readlines()
            print lines[1]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn python and am making a program that will output
I am making a small program that reads a text file and stores it
Lets say I'm making a program that needs to copy all the lines in
I'm making a program that retrieves decently large amounts of data through a python
I'm making a program that uses text files. I need to make it so
I am making a program that automates the seperation of a csv file. We
I am making a program that graphs a line based on data inputted by
I am currently making a program that will send an email if the date
I noticed while making a program that a lot of my int type variables
I'm making a program that communicate with certain patient monitor using C sockets. I'm

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.