Changes

Jump to: navigation, search

OPS435 Python Lab 4

37 bytes added, 17:21, 14 June 2017
PART 2 - Sets
s2 ^ s3 # returns a set containing all values that both sets DO NOT share
s2.symmetric_difference(s3) # same as s2 ^ s3
</source>These powerful features can be useful and efficient. Lists Unfortunately, lists <u>cannot</u> perform these operations on them, instead unless we have to convert the lists into sets. Perform the comparision In order to that, you should first perform a comparison, then convert the list back to a set.  :There are two problems with doing this: First, sets are unordered un-ordered so if the list order is important this will cause problems and remove order, second, sets cannot contain duplicate values, if the list contains any duplicate values they will be deleted. However, if the list does not have any of the above requirements this is a great solution to some problems.<source>
l2 = [1, 2, 3, 4, 5]
l3 = [4, 5, 6, 7, 8]
13,420
edits

Navigation menu