Возвращает только 6399 если заменить return на print всё норм от [6399 ,... ,15999](
from bs4 import BeautifulSoup
def extract_data_from_report(filename):
soup = BeautifulSoup(open(filename, mode="r", encoding="utf-8"), "lxml")
return soup
def article():
items = extract_data_from_report('pro.html').find_all(
'div', class_='catalog-product')
itemPrice = []
for n, i in enumerate(items, start=1):
itemName = i.find(
'a', class_='catalog-product__name').text.lstrip("Материнская плата").partition('[')[0]
if i.find(class_="product-buy__prev") is not None:
itemPrice = i.find(
'div', class_="product-buy__price_active").text.replace(' ', '').replace('₽', '').split()
else:
itemPrice = i.find(
class_="product-buy__price").text.replace("₽", "").replace(' ', '').split()
itemPrice.append(None)
# print(f'{n}: {itemPrice[0]}₽ за {itemName}')
return itemPrice[0]
if __name__ == '__main__':
print(article())
Должно быть(
arr = [6399,
6799,
6899,
6999,
7199,
7499,
7599,
7699,
7799,
8399,
8499,
8499,
8499,
9399,
9999,
10799,
11199,
11499,
12399,
12499,
12899,
14499,
15299,
15999]
print(min(arr))
print(sum(arr) / len(arr))
print(max(arr))