def exclude(n,d): r = [] # The list to return n = int(n); n = str(n); n = list(n) # Turn argument 'n' into a list d = int(d); d = str(d); d = list(d) # Turn argument 'd' into a list n.sort(); d.sort() # Sort the lists, placing the digits numerically # If there are any common digits they will both have the same position if n[1] == d[1]: # Check if the biggest digit in each number is common n.pop(1); d.pop(1) # If so, remove it from both if n[0] == d[0]: # Check if the smallest digit in each number is common n.pop(0); d.pop(0) # If so, remove it from both if len(n) > 0 and len(d) > 0: # Unless we removed all the digits: r.append(str(n[0])) # Append the remaining digit of 'n' r.append(str(d[0])) # Append the remaining digiit of 'd' return r # Return the list else: return 0 # All digits were common in both integer, return 0