Python Forum
Concatenate two dictionaries
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Concatenate two dictionaries
#4
If you want to actually concatenate them you have to use the dict.update() method.

tup = (x.update(y))
This will create a single tuple(dict()):
tup = ({'field1': 'test1', 'field2': 'test2', 'field3': 'test3','field4': 'test4', 'field5': 'test5', 'field6': 'test6'})
as opposed to:
tup = ({'field1': 'test1', 'field2': 'test2', 'field3': 'test3'},
y = {'field4': 'test4', 'field5': 'test5', 'field6': 'test6'})
which is just adding the two dictionaries to a tuple.
Reply


Messages In This Thread
Concatenate two dictionaries - by harish - Oct-11-2019, 06:48 PM
RE: Concatenate two dictionaries - by buran - Oct-11-2019, 06:53 PM
RE: Concatenate two dictionaries - by harish - Oct-11-2019, 07:03 PM
RE: Concatenate two dictionaries - by strngr12 - Oct-12-2019, 04:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Concatenate str JohnnyCoffee 2 2,948 May-01-2021, 03:58 PM
Last Post: JohnnyCoffee
  Concatenate two dataframes moralear27 2 1,894 Sep-15-2020, 08:04 AM
Last Post: moralear27
  can only concatenate str (not "int") to str gr3yali3n 6 4,141 May-28-2020, 07:20 AM
Last Post: pyzyx3qwerty

Forum Jump:

User Panel Messages

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