Intersection in Python

The intersection is one of the most used operations while manipulation sets in python sets, there are 2 ways to do it, with the intersection method or with the and operator, giving 3 sets (a,b,c) let's create 2 sets (d,e) with the set method and with the and operator.

a = {"apple", "banana", "carrot"}

b = {"carrot", "date", "eggplant", "apple"}

c = {"apple", "tomato", "cherry", "carrot"}
 

1- Creating intersection with set method

d = a.intersection(b,c)

print(d) # d = {'apple', 'carrot'}

2 - Creating intersection with and operator

e = a & b & c

print(d) # d = {'apple', 'carrot'}

 

Which one do you use? For me, option 2 is the cleanest.