L = [{"V":"S001"}, {"V": "S002"}, {"VI": "S001"}, {"VI": "S005"}, {"VII":"S005"}, {"V":"S009"},{"VIII":"S007"}] print("Original List: ",L) u_value = set( val for dic in L for val in dic.values()) print("Unique Values: ",u_value)
Here is what the above code is Doing:
1. We have a list of dictionaries.
2. We use a list comprehension to extract all the values from the dictionaries.
3. We convert the list to a set to get the unique values.
4. We print the unique values.