Exclusive values from two Sets in Python

0 votes
In my program, I have two sets which may contain some common values. I want to identify only those values from the two sets which are not common in both (something like an exclusive OR). How can I achieve this?
Mar 26 in Python by Mishti
• 440 points
29 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

There is a direct function available to achieve this - symmetric_difference

Let's say, we have two sets A & B with values as-

A={1,2,3,4} & B={3,4,5,6} and C be the set containing values which are either in A or B but not both. The values in C can be computed as shown below-

Hope this helps.

answered Mar 27 by Mugdha
• 500 points

Related Questions In Python

0 votes
1 answer

How can I compare the content of two files in Python?

Assuming that your file unique.txt just contains ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,710 points
33 views
0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,710 points
36 views
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
415 views
0 votes
2 answers

Extracting data from a JSON file in Python

Here is what i found and was ...READ MORE

answered Nov 27, 2018 in Python by Rupali
3,933 views
0 votes
1 answer

Returning values in python

Place your values in a tuple and ...READ MORE

answered Apr 26, 2018 in Python by Nietzsche's daemon
• 4,260 points
10 views
0 votes
0 answers

what is a bitwise operator in python?

can you show some operations using bitwise ...READ MORE

Apr 8 in Python by Waseem
• 1,990 points
9 views
0 votes
0 answers

what is the logical AND operator in python?

how do i use it in a ...READ MORE

Apr 12 in Python by Waseem
• 1,990 points
17 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
20 views
0 votes
1 answer

Python - Use unique element from a set

The best way to achieve this by ...READ MORE

answered Mar 27 in Python by Mugdha
• 500 points
34 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.