M
M
Mikhail Evseev2022-01-11 18:38:43
Python
Mikhail Evseev, 2022-01-11 18:38:43

How in sets to take each word for a new object?

Good evening, I need to accept a large text in the input, where the names of the objects are separated by a comma, and fit them into a set, so that each object is separate. This is necessary for the next comparison of them with another set (you need to find which objects from the first set are missing in the other). I only thought of entering the objects manually, one at a time through the while loop. But it is necessary to insert a large text consisting of these objects and take each object from it.

isx = set()
treb = set()

a = input()
b = input()

isx.add(a)
treb.add(b)

result = isx ^ treb

print(isx, treb, result)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2022-01-11
@ultraevs

a = {x.strip() for x in input().split(",")}
b = {x.strip() for x in input().split(",")}
print(b - a)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question