Python Forum
Set Output - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Set Output (/thread-23754.html)



Set Output - ghosalsantanuit - Jan-15-2020

Hi i am running below code
color_list_1 = set(["White", "Black", "Red"])
color_list_2 = set(["Red", "Green"])

for i in color_list_1:
    if i not in color_list_2:
        print(i)
        
print(color_list_1.difference(color_list_2))
print(color_list_1-color_list_2)
oddly the results were printing reversed and automatically was corrected

Black
White
{'Black', 'White'}
>>> %Run ListCompare.py
White
Black
{'White', 'Black'}
>>> %Run ListCompare.py
White
Black
{'White', 'Black'}
{'White', 'Black'}
>>> %Run ListCompare.py
White
Black
{'White', 'Black'}
{'White', 'Black'}


RE: Set Output - jefsummers - Jan-15-2020

You don't ask a question, so guessing you want to know why. Sets are unordered collections of unique objects. Unordered means you cannot count on the order.