apple,100,200,150
orange,80,90,85
70
apple,150.0
orange,85.0
def f(s):
res_int = ''.join(i if i.isdigit() else ' ' for i in s).split()
average = sum(map(int, res_int)) / len(res_int)
limit = 70
res_str = ''
for i in s:
if i.isalpha():
res_str = ''.join([res_str, i])
if average > limit:
return f'{res_str},{average}'
else:
return False
lines = []
while True:
try:
line = input()
if line == "":
break
except EOFError:
break
lines.append(line)
for product in f(lines):
print(product)
def process_line(line, limit):
# Разделяем строку на название товара и цены
parts = line.split(',')
name = parts[0]
prices = list(map(int, parts[1:]))
# Вычисляем среднюю цену
average_price = sum(prices) / len(prices)
# Возвращаем строку с названием товара и средней ценой, если она превышает порог
if average_price > limit:
return f'{name},{average_price:.1f}'
return None
def main():
lines = []
while True:
line = input()
if line == "":
break
lines.append(line)
# Последняя строка - это порог
limit = int(lines[-1])
products = lines[:-1]
results = []
for product in products:
result = process_line(product, limit)
if result:
results.append(result)
for res in results:
print(res)
if __name__ == "__main__":
main()
input() не сохраняет значения в списке
res_int = ''.join(i if i.isdigit() else ' ' for i in s).split()