Question: I need to write a program based on two finished programs (listm.py and setunion.py) to implement the intersection operation between two sets of list. The
I need to write a program based on two finished programs (listm.py and setunion.py) to implement the intersection operation between two sets of list. The program should not use the Python built-in list and set related functions and operations. here is listm.py 
here is setunion.py
I'm trying to finish it like this(modify setunion.py and open a new file called intersection.py):
but finally I get the result is: TypeError: 'List' object is not iterable
What's wrong with me?
Help File Edit Format Run Options Window Elass List: def __init__(self, extlist=None): if extlist is None: self.inlist = [] else: self.inlist = extlist def length(L): return len( L inlist) def is empty(L):... if len( L. inlist)==0): return True else: return False def get(L, i): if is empty(L): print("The get() is unsuccessful!") print("The list is empty!") return -1 elif (ilength(L)): print("The get() is unsuccessful!") print("The index given is out of range!") return -1 else: return( L. inlist[i-1]) def locatebyvalue(L, x): position = 1 for item in L. inlist: if x == item: return position else: position = position+1 return -1 def locatebyid(L, idd): position = 1 for item in L. inlist: if item.id == idd: return position else: position = position+1 return -1 def insert(L, i, x); if (ilength(L)+1): print("The insert() is unsuccessful!"). print("The index given is out of range!") else: L.inlist.insert(i-1, x) def delete(L, i): if is empty(L): print("The delete() is unsuccessful!") print("The list is empty!") return elif (ilength(L)): print("The delete() is unsuccessful!") print("The index given is out of range!") return else: del L. inlist[i-1] def display(L):. print(L. inlist) Ln: 1 Col: 0 File Edit Format Run Options Window Help from listan import * def un( seta, setB): n = length( seta) for i in range( length(setB)): x = get(sets, 1+1) k = locatebyvalue( seta, x) if (k==-1): insert(seta, n+1, x) n = n+1 seta = List([1, 2, 3, 4, 5]) setB - List(12, 4, 5, 10, 11]) display( setA) display( setB) un seta, setB) print("The union result is as follows") display( setA) Ln: 1 Col: 0 File Edit Format Run Options Window from listom import * from intersection import * def un( seta, setB): n = length( setA) for i in range(length( setB)): x = get(SetB, i+1) k = locatebyvalue( seta, x) if (k==-1): insert(seta, n+1, x) n = n+1 File Edit Format Run Options Window Help def intersection( seta, setb): setc=[] for nu in seta: if num in setb: setc.append(num) return setc setA = List([1, 2, 3, 4, 5]) setB = Listii2. 5. 10. 11 display( setA) display( setB) un( seta, setB) print("The union result is as follows") display( seta) print("The intersection is:"). print(intersection seta, setB)) Ln: 7 Col: 0 Help File Edit Format Run Options Window Elass List: def __init__(self, extlist=None): if extlist is None: self.inlist = [] else: self.inlist = extlist def length(L): return len( L inlist) def is empty(L):... if len( L. inlist)==0): return True else: return False def get(L, i): if is empty(L): print("The get() is unsuccessful!") print("The list is empty!") return -1 elif (ilength(L)): print("The get() is unsuccessful!") print("The index given is out of range!") return -1 else: return( L. inlist[i-1]) def locatebyvalue(L, x): position = 1 for item in L. inlist: if x == item: return position else: position = position+1 return -1 def locatebyid(L, idd): position = 1 for item in L. inlist: if item.id == idd: return position else: position = position+1 return -1 def insert(L, i, x); if (ilength(L)+1): print("The insert() is unsuccessful!"). print("The index given is out of range!") else: L.inlist.insert(i-1, x) def delete(L, i): if is empty(L): print("The delete() is unsuccessful!") print("The list is empty!") return elif (ilength(L)): print("The delete() is unsuccessful!") print("The index given is out of range!") return else: del L. inlist[i-1] def display(L):. print(L. inlist) Ln: 1 Col: 0 File Edit Format Run Options Window Help from listan import * def un( seta, setB): n = length( seta) for i in range( length(setB)): x = get(sets, 1+1) k = locatebyvalue( seta, x) if (k==-1): insert(seta, n+1, x) n = n+1 seta = List([1, 2, 3, 4, 5]) setB - List(12, 4, 5, 10, 11]) display( setA) display( setB) un seta, setB) print("The union result is as follows") display( setA) Ln: 1 Col: 0 File Edit Format Run Options Window from listom import * from intersection import * def un( seta, setB): n = length( setA) for i in range(length( setB)): x = get(SetB, i+1) k = locatebyvalue( seta, x) if (k==-1): insert(seta, n+1, x) n = n+1 File Edit Format Run Options Window Help def intersection( seta, setb): setc=[] for nu in seta: if num in setb: setc.append(num) return setc setA = List([1, 2, 3, 4, 5]) setB = Listii2. 5. 10. 11 display( setA) display( setB) un( seta, setB) print("The union result is as follows") display( seta) print("The intersection is:"). print(intersection seta, setB)) Ln: 7 Col: 0