yusuke_power = {"Yusuke Urameshi": "Spirit Gun"} hiei_power = {"Hiei": "Jagan Eye"} powers = dict() # Brute force for dictionary in (yusuke_power, hiei_power): for key, value in dictionary.items(): powers[key] = value # Dictionary Comprehension powers = {key: value for d in (yusuke_power, hiei_power) for key, value in d.items()} # Copy and update powers = yusuke_power.copy() powers.update(hiei_power) # Dictionary unpacking (Python 3.5+) powers = {**yusuke_power, **hiei_power} # Backwards compatible function for any number of dicts def merge_dicts(*dicts: dict): merged_dict = dict() for dictionary in dicts: merge_dict.update(dictionary) return merged_dict # Dictionary union operator (Python 3.9+ maybe?) powers = yusuke_power | hiei_power
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter