Answer the question
In order to leave comments, you need to log in
How to read data from one line in Python 3?
Started learning Python and ran into a reading problem (working in PyCharm).
Is it possible to read data as from a single thread in C++?
Input data:
>>>3 4
>>>2 1 4
>>>3 1 3 1
>>>1 2
And immediately I want to calculate how many identical numbers (I just increment the elements equal to the number).
PS I would not like to write down the input data
Answer the question
In order to leave comments, you need to log in
For version 2.7:
# вводим числа через пробел
data = raw_input()
# преобразуем символы в числа
data = map(int,data.split())
from collections import Counter
# подсчитываем, сколько раз встречается каждое значение
ctr = Counter(data)
Counter({4: 3, 1: 2, 2: 2, 3: 2, 5: 1})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question