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

  • Home
  • SEARCH
  • 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 960199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:08:42+00:00 2026-05-16T01:08:42+00:00

I am a beginner and just started learning Python couple days ago (yay!) so

  • 0

I am a beginner and just started learning Python couple days ago (yay!)

so i’ve come across a problem. when i run, this code outputs everything but the text (txt in file is numbers 0-10 on seperate lines)

def output():
    xf=open("data.txt", "r")
    print xf
    print("opened, printing now")
    for line in xf:
        print(xf.read())
        print("and\n")
    xf.close()
    print("closed, done printing")  
  • 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-16T01:08:43+00:00Added an answer on May 16, 2026 at 1:08 am

    This should print out each number on its own line, like you want, in a lot less code, and more readable.

    def output():
        f = open('data.txt', 'r').read()
        print f
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Scala, just started learning, so this is basic beginner question.
I am a beginner in Haskell so please bear with me. (Just started learning
I'm a Python beginner and have just started using packages. When you're calling a
I started programming just few month ago so I am a pure beginner but
I just started to learn jQuery and I came across this site- TEDx Portland
i am a beginner level programmer and have just started learning programming in C++,
I've just started learning C# and had created this simple configuration file generator for
Can anyone tell me how to do this? I've just started learning javascript. I
I just started using Python resp. Rpy2 so I am really a beginner. So
I am a beginner and have just started experimenting with the modeling tool in

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.