{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e39169bf",
   "metadata": {},
   "source": [
    "# 08-23 · Счётчик слов\n",
    "\n",
    "Практика к разделу [«Мини-проект: счётчик слов»](../../site/chapters/glava-08/08-23-mini-proekt-schetchik-slov.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2d327e8c",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Собрать split() и подсчёт в словаре для анализа текста."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6bbcb9ae",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1578cc57",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T16:19:00.900836Z",
     "iopub.status.busy": "2026-08-16T16:19:00.900656Z",
     "iopub.status.idle": "2026-08-16T16:19:00.917566Z",
     "shell.execute_reply": "2026-08-16T16:19:00.917012Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['кот', 'и', 'пёс', 'и', 'кот']\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "text = \"кот и пёс и кот\"\n",
    "words = text.lower().split()\n",
    "print(words)\n",
    "print(len(words))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "09db755e",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Для `text = \"кот и пёс и кот\"` разбейте на слова (`words`), посчитайте их количество (`total`), и через словарь `schetchik` посчитайте, сколько раз встречается каждое слово."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "91b11ae5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T16:19:00.918522Z",
     "iopub.status.busy": "2026-08-16T16:19:00.918416Z",
     "iopub.status.idle": "2026-08-16T16:19:00.921155Z",
     "shell.execute_reply": "2026-08-16T16:19:00.920683Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "{'кот': 2, 'и': 2, 'пёс': 1}\n"
     ]
    }
   ],
   "source": [
    "text = \"кот и пёс и кот\"\n",
    "words = text.lower().split()\n",
    "total = len(words)\n",
    "\n",
    "schetchik = {}\n",
    "for word in words:\n",
    "    schetchik[word] = schetchik.get(word, 0) + 1\n",
    "\n",
    "print(total)\n",
    "print(schetchik)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
