Dec-18-2020, 05:08 AM
You can use oeperator'-' or the difference method
Code:
Code:
print('\nThis program will print out a set containing all colors from color_list_1 {"White", "Black", "Red"} that are not present in color_list_2 {"Red", "Green"}.') color_list_1 = set(["White", "Black", "Red"]) color_list_2 = set(["Red", "Green"]) print(color_list_1 - color_list_2) print(color_list_1.difference(color_list_2))Output:
Quote:This program will print out a set containing all colors from color_list_1 {"White", "Black", "Red"} that are not present in color_list_2 {"Red", "Green"}.
{'Black', 'White'}
{'Black', 'White'}