๐ [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): ...