2

I am making use of set difference to output all the missing elements in a given list as shown in the code snippet bellow.

def missingNum(a, N):
    arr = range(1, N+1)
    res = list(set(arr)-set(a))
    for i in range(len(res)):
        if type(i) != None:
            print(res[i])

N2 = 10
a2 = [1, 2, 4, 5, 6, 7, 8, 10]
print(missingNum(a2, N2))

When I print out my final result I get the expected output with a trailing None as bellow;

Your Output is:
9
3
None

How do I print out just the output without the trailing None ?

cnuvadga
  • 109
  • 1
  • 10

0 Answers0