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 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

Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
Have a matrix report now that has Position, Hours and Wages for a location
I have a dictionary with non unique values and I want to count the
I have a number of Data Transfer Objects (DTO's) that map onto data structures
I have a code that contains verse number and chapter number of the bible.
I have another very puzzling question that has cropped up after my upgrade from
I have a winform data entry and retrieval program called CaseNotes. This has a
I have to build an HTML table that shows data for users versus pages
I have people and places data as: Person entity has IList<DateRangePlaces> each having IList<Place>
I have a dictionary in Python where the keys are pathnames. For example: dict[/A]

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.