Print out a set containing all the colors from a list which are not present in other list

Program

def myfun():
    list_1 = set(["White", "Black", "Red","Orange"])
    list_2 = set(["Red", "Green","Orange"])


    print("Original set elements:")
    print(list_1)
    print(list_2)

    print("\nDifference of list_1 and list_2:")
    print(list_1.difference(list_2))

    print("\nDifference of list_2 and list_1:")
    print(list_2.difference(list_1))
    
if __name__=="__main__":      
    myfun()

Output:

Original set elements:
{'Red', 'White', 'Black', 'Orange'}
{'Red', 'Green', 'Orange'}

Difference of list_1 and list_2:
{'White', 'Black'}

Difference of list_2 and list_1:
{'Green'}


More Questions


17 . Print out a set containing all the colors from a list which are not present in other list
18 . Write a Python program to get current time and date
19 . Write a Python program sort a list in descending order
20 . Python Program to Replace all Occurrences of ‘a’ with $ in a String
21 . Write a Python program to remove duplicates from a list
22 . Write a Python program to count number of vowels in the given string
23 . Write a Python program to check whether a character is an alphabet or not
24 . Write a Python program to count number of digits in an integer
25 . Write a Python program to print fibonacci series
26 . Write a Python program to print reverse number
27 . Write a Python Program to print Palindrome numbers from 1 to 100



For latest job updates join Telegram Channel: https://t.me/sateeshm

Programs