Python Forum
Iterate through a list of dictionary and append a new value.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Iterate through a list of dictionary and append a new value.
#1
I'm trying to iterate through the following dictionary and append in the list .

dic={'Dining': [{'Switchboard': [{'Fan': ['01:45.9166666666']},
                             {'Covelight': ['01:116.5']},
                             {'Light': ['01:182.4']}]}],
 'Kids': [{'Switchboard': [{'Light': ['01:206.8']},
                           {'Fan': ['01:2.58333333333']}]}],
 'Kitchen': [{'MultiSensor': [{'Red': ['01:0.95125']}]},
             {'Switchboard': [{'Light2': ['01:125.2']},
                              {'Light': ['01:176.533333333']},
                              {'Fan': ['01:5.0']}]}],
 'Living': [{'Switchboard': [{'Light': ['01:7.13333333333']},
                             {'Covelight': ['01:17.6']},
                             {'Fan': ['01:6.91666666667']}]},
            {'MultiSensor': [{'Red': ['01:0.508333333333']},
                             {'Green': ['01:4.23333333333']}]}]}
for example if I want to append '02:3.9' in {'Green': ['01:4.23333333333']}
Reply


Messages In This Thread
Iterate through a list of dictionary and append a new value. - by erina - May-16-2019, 08:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sort a list of dictionaries by the only dictionary key Calab 2 685 Apr-29-2024, 04:38 PM
Last Post: Calab
  append str to list in dataclass flash77 6 631 Mar-14-2024, 06:26 PM
Last Post: flash77
  Dictionary in a list bashage 2 625 Dec-27-2023, 04:04 PM
Last Post: deanhystad
  filtering a list of dictionary as per given criteria jss 5 778 Dec-23-2023, 08:47 AM
Last Post: Gribouillis
  How to add list to dictionary? Kull_Khan 3 1,064 Apr-04-2023, 08:35 AM
Last Post: ClaytonMorrison
Question How to append integers from file to list? Milan 8 1,535 Mar-11-2023, 10:59 PM
Last Post: DeaD_EyE
  iterate through the dict_values while unpacking the dictionary PeacockOpenminded 3 1,358 Jan-22-2023, 12:44 PM
Last Post: PeacockOpenminded
  read a text file, find all integers, append to list oldtrafford 12 3,788 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  Using .append() with list vs dataframe Mark17 7 11,012 Jun-12-2022, 06:54 PM
Last Post: Mark17
  check if element is in a list in a dictionary value ambrozote 4 2,065 May-11-2022, 06:05 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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