Answer the question
In order to leave comments, you need to log in
How to sort numbers correctly?
Good evening, please help me figure out what I'm doing wrong. The task is to take a number into the kolvo variable, which will determine the number of repetitions of the for loop. And then distribute the following data into three sets, according to the features:
1. number > 40
2. divisible by 2 without a remainder
3. divisible by 3 without a remainder
After that, you need to find the numbers that are contained in exactly two any sets.
kolvo = int(input())
first = set()
second = set()
third = set()
for i in range(kolvo):
b = input()
if int(b) > 40:
first.add(b)
if int(b) // 2 == 0:
second.add(b)
elif int(b) // 3 == 0:
third.add(b)
elif int(b) // 2 == 0:
second.add(b)
if int(b) // 3 == 0:
third.add(b)
elif int(b) // 3 == 0:
third.add(b)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question