python - Finding keys for a value in a dictionary of integers -
the problem write python function returns list of keys in adict value target. keys , values in dictionary integers , keys in list return must in increasing order. this work have far: def keyswithvalue(adict, target): ''' adict: dictionary target: integer ''' ans = [] if target not in adict.values(): return ans else: key in adict.keys(): if target in adict[key]: ans+=[key] return ans.sort() i keep on getting: "typeerror: argument of type 'int' not iterable" but don't understand means, , how fix it. if help, i'd grateful! the issue here if target in adict[key]: you trying iterate on integer value, wont work. you should instead use if target == adict[key]: you can refactor code this. have made assumption input data looks like. if i'm wrong can adjust answer. d = {1:1, 2:2, 3:3, 4:3, 5:3} def keyswithvalue(adict, targe