đ [Exercise] Collections - Need help đ« Python đ
Hello, I have some trouble with an exercise at school. Was wondering if you could help me solving this, and if possible explaining it as well ? We haven't really seen the Collections yet... ââââââââââ- The following code sample is a naive implementation of the âintersection function, where the intersection of two collections, A and B, is defined as a collection that contains all the elements that are common to both A and B. defâ intersectionâ(âAâ,â Bâ): intersection â=â â[] forâ a âinâ Aâ: â ifâ a âinâ Bâ: intersectionâ.âappendâ(aâ â) â returnâ intersection Write code for each function listed below (union and difference), where: đ The âunion âof two collections, A and B, is defined as a collection that contains all the elements that are in either A or B đ The âdifference âof two collections, A and B, is defined as a collection that contains the elements that are in either A or B, but ânotâ both. def union(A, B): ... def difference(A, B): ...