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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:54:18+00:00 2026-05-31T23:54:18+00:00

properties = [color, font-size, font-family, width, height] inPath = style.css outPath = output.txt #Open

  • 0
properties = ["color", "font-size", "font-family", "width", "height"]


inPath = "style.css"
outPath = "output.txt"

#Open a file for reading
file = open(inPath, 'rU')
if file:
    # read from the file
    filecontents = file.read()
    file.close()
else:
    print "Error Opening File."

#Open a file for writing
file = open(outPath, 'wb')
if file:
    for i in properties:
        search = i
        index = filecontents.find(search)   
        file.write(str(index), "\n")
    file.close()
else:
    print "Error Opening File."

seems to work, but:

  • It only searches a keyword once?
  • Its not writing to the output file. function takes exactly 1 argument
  • I don’t want it to print the index actually, but the number of time the keyword appears.

Many thanks

  • 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-31T23:54:19+00:00Added an answer on May 31, 2026 at 11:54 pm

    First, you want .count(search), not .find(search), if what you’re looking for is # of occurrences.

    Second, .write() only takes a single parameter – if you want to write a newline, you need to concatenate it first, or call .write() twice.

    Third, doing for i in properties: search = i is redundant; just use the name you want in your for loop.

    for search in properties:
        cnt = filecontents.count(search)
        file.write(str(cnt) + "\n")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any way to change font size, font color etc properties at run
outline-style: none; margin: 0px; padding: 2px; background-color: #eff0f8; color: #3b3a39; font-family: Georgia,'Times New Roman',Times,serif;
Say I have a class which specifies a font size, color and may other
With jQuery .animate() , I use to write like .animate({ 'font-size': 24px, 'color': '#555'
With the example below, I need to add padding and background-color properties to the
I got two properties initialized in header file: @property (readwrite, assign) int Figure1; @property
Is there a standard guideline of what order the CSS properties should be in?
I have a design in an psd file. So I copied all text properties
I have to get needed css property of element (properties may be inherited from
I'm not that great at CSS. I get how the properties work together but

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.