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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:00:11+00:00 2026-05-24T06:00:11+00:00

It seems like this is a common problem, but I can’t seem to find

  • 0

It seems like this is a common problem, but I can’t seem to find a solution.

I have a Python3 script containing two dictionaries sqldict and hitsdict. This code outputs dictionary values, if sqldict[value][0] == hitsdict[thing][1].

for value in sqldict:
        for thing in hitsdict:
            if sqldict[value][0] == hitsdict[thing][1]:
                print(hitsdict[thing][1],sqldict[value][5])

I would also like to get the keys that are associated with the values that match the sqldict[value][0] == hitsdict[thing][1] comparison, but I can’t seem to figure out how to get the associated keys? I was trying to do something like this:

for key, value in sqldict.items():
        for thing in hitsdict:
            if sqldict[value][0] == hitsdict[thing][1]:
                            print(key,hitsdict[thing][1],sqldict[value][5])

Can anyone explain what my problem is and how I can get the keys from values that pass my, if sqldict[value][0] == hitsdict[thing][1] comparison? Thank you!

EDIT:
One idea I had is to add the key as an addition value. Is there another more pythonic way?

  • 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-24T06:00:12+00:00Added an answer on May 24, 2026 at 6:00 am

    You are finding values by looping through the items in the dictionary. That’s the wrong way. The whole purpose of the dictionary is to use the keys to look things up.

    In short, your datastructure is completely messed up. Since we don’t know how it looks, we can’t tell you how it should look, but on the other hand, you have the word “sql” in one of the values.

    May I suggest you use SQL queries to do whatever you do instead?

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

Sidebar

Related Questions

This seems like a very simple and a very common problem. The simplest example
This seems like it would be a common issue to be but I don't
I feel like this is a stupid question because it seems like common sense
Seems like this should be obvious, but how do I send arrow key presses
Seems like this should be simple, but powershell is winning another battle with me.
It seems like this should be straightforward but I'm boggling. I've got my listview
Can this be done? It seems like this should be possible. In general, I
As popular as Ruby and Rails are, it seems like this problem would already
This seems to be a very common problem of mine: data = [1 2
This seems like an obvious question but there does not appear to be an

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.