mass = [int(s) for s in input('введите элементы через пробел ').split()]
mass_num = []
summ = 0
for i in range(len(mass)):
if mass.count(mass[i]) > 1 and mass[i] not in mass_num:
mass_num.append(mass[i])
summ += mass[i] * mass.count(mass[i])
print(mass)
if mass_num:
print('YES')
for number in mass_num:
print(f'кол-во "{number}" = {mass.count(number)}')
print('сумма =', summ)
else:
print('NO')
Объяснение:
mass = [int(s) for s in input('введите элементы через пробел ').split()]
mass_num = []
summ = 0
for i in range(len(mass)):
if mass.count(mass[i]) > 1 and mass[i] not in mass_num:
mass_num.append(mass[i])
summ += mass[i] * mass.count(mass[i])
print(mass)
if mass_num:
print('YES')
for number in mass_num:
print(f'кол-во "{number}" = {mass.count(number)}')
print('сумма =', summ)
else:
print('NO')
Объяснение: