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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:04:55+00:00 2026-06-05T03:04:55+00:00

a = [{43:123}, {3:103}, {36:103}, {2:102}, {23:100}] How can I extract id from it

  • 0

a = [{43:123}, {3:103}, {36:103}, {2:102}, {23:100}]

How can I extract id from it when each of the keys is id and value means a number of points.
I tried use this:

for b in a: 
     print a[i].keys()
     i+=1

Python result is a list, but I need integer type. eg
print a[2].keys() result [36] and I need 36 which is int. Thx

  • 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-05T03:04:57+00:00Added an answer on June 5, 2026 at 3:04 am

    Access the first element from such list:

    a[2].keys()[0]
    

    or

    next(a[2].iterkeys())
    

    both returning the int 36.

    To get a list of all keys:

    [next(d.iterkeys()) for d in a]
    

    returning [43, 3, 36, 2, 23]

    Maybe you should convert your list of dicts into a simple dict:

    d = {}
    for x in a:
        d.update(x) 
    

    obtaining {2: 102, 3: 103, 23: 100, 36: 103, 43: 123}, where you can get all keys with simple d.keys() and obtaining [3, 2, 43, 36, 23], although the order is not conserved.

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

Sidebar

Related Questions

I have 123 tables as well: M001 -> M010 -> M123. each is a
'123xswer' How to retrieve 123 from the string above without using regular expression?
I am trying to use the ImageLoader class from libs-for-android (http://code.google.com/p/libs-for-android/), and am getting
Assuming I have the following data: id PGroup Number 103 AAA 9946 103 BBB
123-reg are my web host and they dont have a control panel to convert
myClass(123); ?> this works, but returns this warning: Warning: Missing argument 1 for myClass::myClass()
Given: ABC content 1 123 content 2 ABC content 3 XYZ Is it possible
I have this string: 123-456-7 I need to get this string: 1234567 How I
It's 123.98699999999999 ! Why is that?
a = ['123', '2', 4] b = a[4] or 'sss' print b I want

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.