How can I create this in Python? I am new to Python and I am struggling with this problem.

Screen Shot 2020-09-22 at 11.19.41 PM|690x206

Here are some good questions to ask yourself when creating a new program.

  • What should my program accomplish?
  • What would be a starting point to answer the question?
  • What steps do I need to take to answer the question?

This seems like a school assignment. As per this forum’s policy, we can only help out with any questions you may have, not provide solutions. Additionally, some context behind the meanings of “intersection” and “union” would be helpful for anyone trying to help out.

1 Like

Indeed! Also, if you tried writing out how you would do this on paper, then write out instructions that you would give someone else, if they tried to do this task. Then, you should be able to translate those written instructions into code.

Intersection vs union

Intersection is every element of one set which is also in another, and union is every element in the first set, and every element in the second set which isn’t in the first set.


Thank you! My professor didn’t give us a good introduction to python and I been taking it over here but is confusing because I am also taking Java for another class. I will try to do my best! Those questions helped me to have a better idea of what I am going to write in Python.

Yes, there are quite a few differences between Java and Python (I’ve learned both myself). It might help to remember that the overall concepts are the same. Even though the syntax and other aspects of the languages are different, concepts like variables, lists/arrays, conditionals, loops, and OOP (object-oriented programming) and the logic behind them are similar in many programming languages.

No problem! If you have any more questions, feel free to post them here and I’ll try my best to help out.

1 Like