I am trying to combine two dictionaries, after searching a closed question about stack overflow, I found the following solution:
mergeDicts = {**dict1, **dict2}
but that will not work. Although I know that my code is fine, as I observe the correct results for one dictionary, as soon as I merge, I do not get the correct results
def readFiles(path1):
// count words
if __name__ == '__main__':
a = readFiles('C:/University/learnPy/dir')
b = readFiles('C:/Users/user/Anaconda3/dir')
bigdict = {**a, **b}
print(a['wee'])
print(b['wee'])
print(bigdict['wee'])
In athere is 1 .txtfile containing 2 wee
In bthere is 1 .txtfile containing 1 wee
Thus, I expect that the output of bigdict will be 3, but what I observe is bigdict, just getting the numbers of the first dict. {**dict1 (THIS ONE), **dict2}, and merging does not work.
Question: what went wrong? why it doesn't work on python 3.6 when the answers claim it should work.