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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:10:09+00:00 2026-06-15T04:10:09+00:00

I have a dictionary in python with date tuples as keys and data tuples

  • 0

I have a dictionary in python with date tuples as keys and data tuples as the values.

An example might be:

(1900, 1): (2.0, 3.0, 4.0)

where 1900 is the year 1900 and 1 is the first month, January.

The key tuples follow like so: (1900, 2), (1900, 3) and so on.

How can I iterate over a dictionary like this? Specifically the first month of every year, so the key set would look like (1900, 1)…(1910, 1) with the first item in the tuple incrementing, but the second staying the same.

Thank you for any help you can give me, since I am relatively new to python.

  • 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-06-15T04:10:10+00:00Added an answer on June 15, 2026 at 4:10 am
    for key in sorted(my_dict, key=operator.itemgetter(1,0)):
        print(my_dict[key])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dictionary in Python where the keys are pathnames. For example: dict[/A]
I have data in a python dictionary that I'd like to store in a
I need to break down a date in python into: year, month, day and
I know you can have spaces in Python dictionary keys, but is that considered
Let's say that I have a Python dictionary, but the values are a tuple:
In python I have a dictionary that maps tuples to a list of tuples.
I have a python dictionary of type defaultdict(list) This dictionary is something like this:
I have a process that pickles a dictionary using Python 3.2. I then need
I'm newish to Python (and stackoverflow)...bear with me! I have a dictionary that looks
I have a python function that randomize a dictionary representing a position specific scoring

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.