"<p>In this video we are going to discover together Python Sets.How they works and why we need them in some cases.<br /> <br /> A Set is one of the four data types built into Python used to store data sets, the other three are <a href="https://www.devbrains.tn/tutorials/data-structures-lists">List</a>, <a href="https://www.devbrains.tn/tutorials/data-structures-tuples">Tuple</a>, and <a href="https://www.devbrains.tn/tutorials/python-dictionaries">Dictionary</a>, all with different properties and uses.<br />  </p> <p>In Python, <strong>Set </strong>is an unordered collection and has no duplicate elements. The order of the elements in a set is undefined, though it may consist of various elements.</p> <p>The major advantage of using a set, as opposed to a list, is that it has a highly optimized method for checking whether a specific element is found in the set or not.</p> <pre> <code>>>>a = {"chat","chien","poisson","chat","poisson"} >>>a {'chat', 'chien', 'poisson'} >>>a = set("devbrains") >>>a {'s', 'r', 'a', 'e', 'd', 'v', 'i', 'n', 'b'} >>>a = set("devbrains") >>>a {'s', 'r', 'a', 'e', 'd', 'v', 'i', 'n', 'b'} >>>a = {"chat","chien","poisson","chat","poisson"} >>>a {'chat', 'chien', 'poisson'} >>>b = {"chat","chien","serpent","chaton","oiseaux"} >>>b {'serpent', 'chat', 'chaton', 'oiseaux', 'chien'} >>>a {'chat', 'chien', 'poisson'} >>>a | b {'serpent', 'oiseaux', 'chien', 'chat', 'chaton', 'poisson'} >>>a - b {'poisson'} >>>a ^ b {'serpent', 'chaton', 'oiseaux', 'poisson'} >>>a {'chat', 'chien', 'poisson'} >>>b {'serpent', 'chat', 'chaton', 'oiseaux', 'chien'} >>>a & b {'chat', 'chien'}</code></pre>"