HW4Q5
user_7676782
python
2 years ago
675 B
5
Indexable
# this func get a line from a file and split it to a list def makeList(file): line = file.readline() myList = line.split() return myList def main(): fileContent1 = open('file1', 'r') fileContent2 = open('file2', 'r') mySet1 = set(makeList(fileContent1)) mySet2 = set(makeList(fileContent2)) print(mySet1) print(mySet2) # union of two sets mySet3 = mySet1.union(mySet2) print(mySet3) # Difference of two sets mySet4 = mySet1 - mySet2 mySet5 = mySet2 - mySet1 print(mySet4) print(mySet5) # Symmetric Difference of sets mySet6 = mySet1 ^ mySet2 print(mySet6) main()
Editor is loading...