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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:39:51+00:00 2026-05-28T01:39:51+00:00

Another python-dictionary question :) here’s my dictionary: mydict = {key1: valueA, key2: valueA, key3:

  • 0

Another python-dictionary question 🙂

here’s my dictionary:

mydict = {key1: valueA, key2: valueA, key3: valueB, key4: valueA,
key5: valueA, key6: valueB, key7: valueB, key8: valueA, key9: valueB}

now i want to iterate through the dictionary only for the key-value-pairs of
key4, key5, key6 and key7 and check if the value is valueB.
i hope it is possible to understand what i mean..

i want to create a for-loop, and only if the value of key4 is valueB, the content of the loop should be executed, then, if the value of key5 is valueB, it should be executed again, and so on. thanks in advance

  • 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-28T01:39:52+00:00Added an answer on May 28, 2026 at 1:39 am
    for key in [key4, key5, key6, key7]:
        if mydict[key] == valueB:
            pass # do stuff here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read on another Stack Overflow question that Python was just like Ruby, as
Now following my series of python newbie questions and based on another question .
This question is in relation to another question asked here: Sorting 1M records I
I asked another question: https://stackoverflow.com/questions/1180240/best-way-to-sort-1m-records-in-python where I was trying to determine the best approach
Here's a function (credit to user Abbot, for providing it in another question) def
this may sound like a strange question from a Python noob, but here's the
Let's assume I have a main script, main.py, that imports another python file with
I'm trying to call a function inside another function in python, but can't find
I want to run a python script from within another. By within I mean
If I have a python class, how can I alias that class-name into another

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.