Find the difference between two collections. The difference means that either the character is present in one collection or it is present in other, but not in both. Return a sorted set with difference.

The collections can contain any character and can contain duplicates.

For instance:

A = [a,a,t,e,f,i,j]

B = [t,g,g,i,k,f]

difference = [a,e,g,j,k]

Difficulty: introductory

Starter code:

def diff(a, b):
	

Solutions:
def diff(a, b):
    return sorted(set(a) ^ set(b))

def diff(a, b):
    return sorted(set(a).symmetric_difference(b))

# return a sorted set with the difference
def diff(a, b):
  a = set(a)
  b = set(b)
  c = a.symmetric_difference(b)
  return sorted(list(c))

# return a sorted set with the difference
def diff(a, b):
    return sorted(list(set(a).symmetric_difference(set(b))))

# return a sorted set with the difference
def diff(a, b):
  return sorted(set(a).symmetric_difference(set(b)))

diff=lambda a,b: sorted(set([e for e in a if e not in b]+[e for e in b if e not in a]))

# return a sorted set with the difference
def diff(a, b):
    c = []
    for i in a:
        if i not in b and i not in c:
            c.append(i)
    for i in b:
        if i not in a and i not in c:
            c.append(i)
        
    return sorted(c)

def diff(a, b):
    a,b=set(a),set(b)
    return sorted((a-b).union(b-a))

def diff(a, b):
    first = []
    second = []
    for element in a:
        if element not in b:
            first.append(element)
    for word in b:
        if word not in a:
            second.append(word)
    third = first + second
    third = sorted(third)
    for element in third:
        if third.count(element) > 1:
            third.remove(element)
    return third

# return a sorted set with the difference
def diff(a, b):
    output = []
    for elem in a:
        if elem not in b:
            output.append(elem)
    for elem in b:
        if elem not in a:
            output.append(elem)
    return sorted(list(set(output)))