What I am attempting to accomplish is to create a union of two dictionaries (consisting of single integers i.e. 1, 2, 3, 4, etc.) by taking the keys out of the dictionary, putting them into two lists, joining the two lists and then putting them back into a new dictionary that contains both lists. However, I am running into the
TypeError: unsupported operand type(s) for +:
'builtin_function_or_method' and 'builtin_function_or_method'
How would I get around this error?
Here are the relevant pieces of code.
class DictSet:
def __init__(self, elements):
self.newDict = {}
for i in elements:
self.newDict[i] = True
def union(self, otherset):
a = self.newDict.keys
b = otherset.newDict.keys
list1 = a + b
new = DictSet(list1)
return new
def main():
allints = DictSet([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
odds = DictSet([1, 3, 5, 7, 9])
evens = DictSet([2, 4, 6, 8, 10])