M
M
Mikhail Evseev2022-01-10 20:04:01
Python
Mikhail Evseev, 2022-01-10 20:04:01

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

1 answer(s)
K
Kadabrov, 2022-01-10
@Kadabrov

the remainder of the division
you need 3 conditions
1. number > 40
2. divisible by 2 without a remainder
3. divisible by 3 without a remainder

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question