{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fecc262c",
   "metadata": {},
   "source": [
    "# 12-08 · Debug Lab — счётчик\n",
    "\n",
    "Практика к разделу [«Строим проект по шагам»](../../site/chapters/glava-12/12-08-stroim-proekt-po-shagam.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d63f0489",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Найти и исправить ошибку: счётчик обнуляется внутри цикла."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f1569102",
   "metadata": {},
   "source": [
    "## Сломанный код (не выполняем)\n",
    "\n",
    "```python\n",
    "for correct, given in zip(answers, user_answers):\n",
    "    score = 0\n",
    "    if given == correct:\n",
    "        score += 1\n",
    "```\n",
    "\n",
    "`score = 0` стоит ВНУТРИ цикла — счётчик никогда не накапливается."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3ba88fab",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика — исправленная версия"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "013c4245",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:38:29.987201Z",
     "iopub.status.busy": "2026-08-17T16:38:29.987003Z",
     "iopub.status.idle": "2026-08-17T16:38:30.005145Z",
     "shell.execute_reply": "2026-08-17T16:38:30.004719Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Итоговый счёт: 2\n"
     ]
    }
   ],
   "source": [
    "answers = [\"python\", \"git\", \"sql\"]\n",
    "user_answers = [\"python\", \"python\", \"sql\"]\n",
    "\n",
    "score = 0\n",
    "for correct, given in zip(answers, user_answers):\n",
    "    if given == correct:\n",
    "        score += 1\n",
    "\n",
    "print(\"Итоговый счёт:\", score)"
   ]
  }
 ],
 "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
}
