Python Forum
Question about working with dictionaries
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about working with dictionaries
#11
You made it happen :)

It works now. I had to remove the [] in the JIRA dict.

Thank you so much for your help.
Reply
#12
In the meantime there is another use case causing some struggle :(
I want to read the components of an issues and save these components to an one-dictionary list. The problem is: the amount of components within one issue can be flexible.

I can read and display the components for an issue using a

for component in components
(…)
But I do not know how to store it as one-dictionary list?! I tried with append but this does not solve my problem. Can I get another hint from you?
Reply
#13
From a prior post:
components = [
    { "name": "Linux" },
    { "name": "Mint" }
]
I would call this a list of dictionaries. Is this what you mean "one-dictionary list"? You should have no trouble appending dictionaries to this list.
components.append({"name": "Something else"})
#or extending the list
components.extend(({"name": 1}, {"name": "two"}))
#or concatenating lists
components = components + [{"name": 3}, {"name": "four"}]
Reply
#14
(Dec-27-2022, 08:41 PM)deanhystad Wrote: From a prior post:
components = [
    { "name": "Linux" },
    { "name": "Mint" }
]
I would call this a list of dictionaries. Is this what you mean "one-dictionary list"? You should have no trouble appending dictionaries to this list.
components.append({"name": "Something else"})
#or extending the list
components.extend(({"name": 1}, {"name": "two"}))
#or concatenating lists
components = components + [{"name": 3}, {"name": "four"}]

This looks promising :) I tried with append command but then I seems to have done something wrong :( …so I was close but not that near :D I will give it another try. Thank you for your help :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Quick Question about Dictionaries Extra 6 1,848 Apr-29-2022, 08:34 PM
Last Post: Extra
  Noob question: why is shapesize() not working for my turtle adifrank 8 5,829 Sep-09-2020, 11:13 PM
Last Post: adifrank
  Working with files and dictionaries OmarSinno 1 2,620 Oct-30-2017, 11:02 AM
Last Post: wavic
  Working with dictionaries and keys netrate 9 5,856 Jun-01-2017, 05:29 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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