![]() We’ve looked at Python sets, and how they differ from other sequence types like lists and tuples. Look at other solutions, like using lists or converting your set to a list. If you think you need set indexing, you might be thinking in the wrong direction. Sets have no order, and thus can’t be indexed. If you were hoping to access set elements by using indexing (e.g. Remove and return an arbitrary element from the set (raises KeyError if the set is empty) Remove element from the set if it is present (save you a presence check) In the next table, I listed some extra operations that you can use to manipulate sets: Name The above works for intersections (&) and difference (-) too.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |