Python Forum
How to access specific values from a dict?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to access specific values from a dict?
#3
(Feb-05-2020, 06:24 PM)micseydel Wrote:
(Feb-05-2020, 05:03 PM)t4keheart Wrote: I want to be able to pull specific lines, by referencing the associated numbers on the left...
Could you elaborate on this? I read your post 3 times trying to figure out your question, and this seems like it, but I don't know what it means, when it comes down to code.

I'm sorry if I wasn't clear. I will modify my post to try to be more direct about what I'm asking.

I need to write a function that takes the dictionary I posted in the original post as input, and returns only the last entry's 'body' value.
5366005: {'body': 'testing sms ID', 'msg_id': 5366005}}}
So, 'testing sms ID' would be returned in this case.

I would also like to write a function that can be passed the msg_id (the number on the left for each entry, or key) and return the corresponding 'body' value.

for example, input '5366005' would also return 'testing sms ID'.

I'm not quite sure what I'm working with here which has made it difficult to research solutions. Is that a dictionary of dictionarys? A dictionary of lists?

Thank you for your time.
Reply


Messages In This Thread
RE: How to access specific values from a dict? - by t4keheart - Feb-05-2020, 06:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to access values returned from inquirer cspower 6 1,161 Dec-26-2023, 09:34 PM
Last Post: cspower
  Printing specific values out from a dictionary mcoliver88 6 1,645 Apr-12-2023, 08:10 PM
Last Post: deanhystad
  Creating a numpy array from specific values of a spreadsheet column JulianZ 0 1,282 Apr-19-2022, 07:36 AM
Last Post: JulianZ
  dict class override: how access parent values? Andrey 1 1,779 Mar-06-2022, 10:49 PM
Last Post: deanhystad
  Sum the values in a pandas pivot table specific columns klllmmm 1 4,886 Nov-19-2021, 04:43 PM
Last Post: klllmmm
  Removing nan values from a dict tomtom 8 7,692 Oct-05-2021, 06:44 PM
Last Post: tomtom
  Annotating plot bar from values of other a specific column celinafregoso99 0 2,070 Mar-10-2021, 03:19 PM
Last Post: celinafregoso99
  Trouble with converting list , dict to int values! faryad13 7 4,010 Sep-04-2020, 06:25 AM
Last Post: faryad13
  Check for specific values on screen and2handles 2 2,509 Jun-17-2020, 05:24 AM
Last Post: and2handles
  access dictionary with keys from another and write values to list redminote4dd 6 3,490 Jun-03-2020, 05:20 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020