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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:39:12+00:00 2026-06-18T15:39:12+00:00

I am working from a Mac and have a question about a python for

  • 0

I am working from a Mac and have a question about a python for look.
I am using a .txt file called rectangle.txt and inside the file it looks like this:

abcde
fghij
klmno

I need to read these in using stdin. But this is what I need my program to:

afk
bgl
chm
din
ejo

So far, I have a program that reads all the lines and splits them and prints them out.
CODE EDITED

So when I changed my code to this:

for line in sys.stdin.readline():
    ls1 = line
    print ls1

I received the list:

a
b
c
d
e

So now I just need to loop through those other ones, but I can’t figure that out

I am running this function from the command line:

python rectangle.py < rectangle.txt

I am trying to learn all of this, so instead of giving me the answer, I would like someone to help explain this to me, in a way hopefully I can understand.

Also, in addition to this .txt file input. My program will also be test with these inputs:

123
456
789

and

A
B
C

All doing the same thing as above. Thank you again in advance for helping me. I have been working on this for hours and can’t seem to figure it out.

  • 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-18T15:39:13+00:00Added an answer on June 18, 2026 at 3:39 pm

    I’m assuming the input in each line has to be the same length.

    In this case have a list of the input strings and for the length of one of these strings loop.

    [“abcde”, “fghij”, “kilmn”] from here here what do you notice about the pattern of the first character from each string? “a” + “f” + “k”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question regarding using KVO-compliant methods to insert/remove objects from an array.
I have a mac with a custom PHP 5 install that built from about
I recently published a question about building this Mac product browser animation using jQuery.
I'm working from a JavaScript book and would like to create some menus using
I have a working script from someone, there in is this line: this.event =
I'm porting some (working) code from Linux to Windows 8. I'm using DDK. typedef
I'm new to working on a Mac and have had Time Machine backing up
I'm working on a project that i have to use ruby 1.8.7. I'm using
I'm working on Mac App Store sandboxing but have an app that was rejected
I'm trying to copy extended attributes from one file to another using the OSX

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.