iterator ()creates and returns an iterator that can be used to iterate over the collection of items example use to illustrate the use of the set adtwe create and use sets containing the courses currently being taken by two students in the following code segmentwe create two sets and add elements to each the results are illustrated in figure smith set(smith add"csci- smith add"math- smith add"hist- smith add"econ- roberts set(roberts add"pol- roberts add"anth- roberts add"csci- roberts add"econ- smith set "csci- "math- "econ- "hist- roberts set "csci- "pol- "econ- "anth- figure abstract view of the two sample sets nextwe determine if the two students are taking the exact same courses if notthen we want to know if they are taking any of the same courses we can do this by computing the intersection between the two sets if smith =roberts print"smith and roberts are taking the same courses else samecourses smith intersectionroberts if samecourses isempty(print"smith and roberts are not taking any of ""the same courses else print"smith and roberts are taking some of the ""same courses:for course in samecourses printcourse