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

The Archive Base Latest Questions

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

Python newbie here and wanted to know if there was a way to combine

  • 0

Python newbie here and wanted to know if there was a way to combine two lists into a dictionary in a way where value can be a specific number. Here’s an example of the 3 datasets I’m trying to combine:

[17, 39, 9]  [13, 37, 13]  =  0.13517353359
[17, 39, 9]  [15, 38, 10]  =  0.055003044449
[13, 39, 13]  [13, 37, 13]  =  0.0345037548204
[13, 39, 13]  [15, 38, 10]  =  0.0801704891415
[14, 39, 12]  [13, 37, 13]  =  0.0596711995129
[14, 39, 12]  [15, 38, 10]  =  0.055003044449
[15, 39, 11]  [13, 37, 13]  =  0.0848386442054
[15, 39, 11]  [15, 38, 10]  =  0.0298355997564
[16, 39, 10]  [13, 37, 13]  = 0.110006088898
[16, 39, 10]  [15, 38, 10]  =  0.0298355997564

I really want to be able to sort the numbers(I have a function that does this working already) and want to lookup by the first list(but need the second list as a reference).

I thought of doing something like name = "%s-%s" % ([16, 39, 10], [15, 38, 10]) then adding name to a dict(with the number being the value) but the problem with this I couldn’t search [16, 39, 10] to get the result. I could make a dict like {[16, 39, 10]:[[15, 38, 10], 0.0298355997564]} but then my search function breaks.

I suspect I might have to do something wonky, but I was wondering if there was a better way to approach this? Ideally I want a simple dict like {[16, 39, 10]:0.0298355997564} and [15, 38, 10] being some kind of attribute that I can reference when needed).

Is this possible?

edit: more details: I need it(reference, second list) there in case I need to reference it later(in this specific example, when I come across a duplicate for [16, 39, 10] I would use the second list to differinate between the results but in my full dataset there aren’t many duplicates so its just to refer to in specific cases).

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

    Lists can’t be dictionary keys, since they are mutable. If the data is static you can convert it to a tuple and use that as a key. The values can also be a tuple of the second list and float value.

       data = {
            (17, 39, 9):  ([13, 37, 13], 0.13517353359),
            (17, 39, 9):  ([15, 38, 10], 0.055003044449),
            (13, 39, 13):  ([13, 37, 13], 0.0345037548204),
       }
    
       print "Other list:", d[(17, 39, 9)][0]
       print "Float", d[(17, 39, 9)][1]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python newbie here. I'm writing a script that can dump some output to either
Newbie python here. How can I break out of the second while loop if
I'm newbie in Python. I can't understand why this code does not work: reOptions
Hey there, was wondering if anyone could help a newbie on SQL and Python.
python newbie here. I'm writing the code to control an experiment that has multiple
I am a Python newbie coming from a C++ background. While I know it's
I'm a Python(3.1.2)/emacs(23.2) newbie teaching myself tkinter using the pythonware tutorial found here .
I'm a Python newbie, so I'm sure this is easy. Here's the code in
I am a newbie in Python. I can understand what a for loop does,
OK - Python newbie here - I assume I am doing something really stupid,

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.