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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:04:42+00:00 2026-05-21T05:04:42+00:00

I have a verses dictionary that contains these values: {cluster1: 0, cluster2: 0, cluster3:

  • 0

I have a verses dictionary that contains these values:

{cluster1: 0, cluster2: 0, cluster3: 0}

i have a data file that has been read in and each line in the file has been represented as a string in a dictionary like this.

 [ "0,1,0,0,0,0,0,0,0,1,1,No,cluster3"," 0,1,0,0,1,0,0,0,0,1,1,No,cluster2" ]

I want to be able to, for each line in the data file (represented as a string in a list), go through the dictionary and compare the Key values eg. cluster1 to see if it contains the substring “cluster1” 2 or 3. and then update the value in the dictionary accordingly. So the aim of the programme is to count the occurences of each cluster and have this represented as a dictionary with the clusternumber and the corresponding counts for each cluster.

I`m just not sure on the syntax to do this. here is my loop so far:

for verse in verses:
    for clusters[Key] in clusters:
        if clusters[Key] in verse:
            clusters.add(Key, +1) # tries to increment the value of 
                                  # the key if the key is in the string verse.
        else:
            print "not in"

Could someone give me some advice on where to go?

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-21T05:04:43+00:00Added an answer on May 21, 2026 at 5:04 am

    You’re quite close. You need to look through keys of the dictionary:

    for verse in verses:
      for k in cluster:
        if k in verse:
          clusters[k] += 1
        else: print "not in"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to build an HTML table that shows data for users versus pages
I have a winform data entry and retrieval program called CaseNotes. This has a
I have a dictionary with non unique values and I want to count the
I know there have been questions in the past about SQL 2005 versus Lucene.NET
I have a dictionary in Python where the keys are pathnames. For example: dict[/A]
I have an application that allows administrators to specify valid IP addresses from which
I have an application that reads a database and outputs alerts to any dependencies
have different files with same name, in different directories. In these files there are
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could

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.