#### Exercise 204

Write a Python program as function which takes as parameters two sets E and F, such that E included in F and returns the complement of F in E. Example if

`E = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}`

and

`F = { 'c', 'd', 'e', 'h'}`

The function returns:

`{'a', 'b', 'f', 'g'}`

#### Solution

`def complemntSets(E , F):`

# initializing the complment of set F

Complement_F = set({})

for x in E:

if x not in F:

Complement_F.add(x)

return Complement_F

# Testing algorithm

E = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}

F = { 'c', 'd', 'e', 'h'}

print("Complement_F = " , complemntSets(E , F))

# display: Complement_F = {'f', 'g', 'a', 'b'}

**Younes Derfoufi**

my-courses.net

my-courses.net