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