Python Practice › Set Programs › Program 28

Symmetric difference in place

EasySet Programs · 28 of 48

Write a Python program to update a set to the symmetric difference with another set.

Advertisement
Input
{1, 2, 3}, {3, 4}
Output
{1, 2, 4}

Approach

  1. ^=.

Solution

Python
a = {1, 2, 3}a ^= {3, 4}print(a)
Output
{1, 2, 4}

Learn the concept

New to this topic? Read the lesson, then come back.

More set programs

← All 48 Set Programs

Leave a Comment