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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:05:20+00:00 2026-05-26T13:05:20+00:00

source = open(file1) out = open(file2, w) days = [‘Mon’,’Tue’,’Wed’,’Thu’,’Fri’,’Sat’,’Sun’] for line in source:

  • 0
source = open("file1")    
out = open("file2", "w")

days = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']

for line in source:
    out.write(line)
    if line.startswith('HERE IS WHERE I WOULD LIKE THE DAYS TO BE LOOPED'):
        break    
out.close()
  • 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-26T13:05:21+00:00Added an answer on May 26, 2026 at 1:05 pm

    Looking at help(str.startswith), you can see that the method accepts a tuple of strings to search for, so you can do it all in one step:

    >>> 'Mon is the first day'.startswith(('Mon','Tue','Wed','Thu','Fri','Sat','Sun'))
    True
    

    Here is a variant that runs on older versions of Python:

    >>> import re
    >>> days = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']
    >>> pattern = '|'.join(days)
    >>> if re.match(pattern, 'Tue is the first day'):
            print 'Found'
    
    Found
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm venturing out of the world of .NET and into the world of open-source.
Suppose I have a source file open and I launch a shell. I can
These two files are mostly seen in open source projects. What are they for,
Is there an open source alternative (similar to ultraedit) to handle files with filesize
Is there a free or open source library to read Excel files (.xls) directly
Is there a free/open source BAR GRAPH (2d) component or sample file for Flash
Suppose I have a source file that is 18218 bytes. I open the file
I'm publishing an open-source library on CodePlex, and want the dll files to have
In the course of programming we encounter large javascript files which are open source
I'm trying to write a multi-file patch for an open-source project, but the master

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.