Is there a ways to merge two similar dictionaries, and what happens if the key words clash?
bumsfeld
413
Nearly a Posting Virtuoso
Recommended Answers
Jump to PostHi bumsfeld,
Well, the naive solution might be something like this:
a, b = dict(), dict() a["a_one"], a["a_two"], a["a_three"] = "a1", "a2", "a3" b["b_one"], b["b_two"], b["b_three"] = "b1", "b2", "b3" for k in a.keys(): if b.has_key(k): continue else: b[k] = a[k] print b
After the loop …
All 4 Replies
G-Do
19
Junior Poster
mawe
6
Junior Poster
G-Do
19
Junior Poster
bumsfeld
413
Nearly a Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.