{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7bf07c78",
   "metadata": {},
   "source": [
    "# 10-17 · Znajdź błąd w pętli\n",
    "\n",
    "Praktyka do sekcji [„Pętle debugowania”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dc754bb9",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Naucz się rozpoznawać i korygować typowe błędy cyklowe."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e0bb1238",
   "metadata": {},
   "source": [
    "## Zepsuty kod (NIE uruchamiać w tej formie)\n",
    "\n",
    "Oto kod błędu nr 4 z tutoriala „Debug Loops”\n",
    "\n",
    "```python\n",
    "chisla = [3, 8, 12, 5, 16, 9, 20]\n",
    "for n in chisla:\n",
    "    chetnye_count = 0   # ошибка: обнуляется на каждой итерации!\n",
    "    if n % 2 == 0:\n",
    "        chetnye_count += 1\n",
    "```\n",
    "\n",
    "W komórce poniżej — zadanie: napisz **poprawioną** wersję, która naprawdę liczy łączną liczbę liczb parzystych."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9b8720ff",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadania ★ – Naprawa błędu nr 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e9624b12",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:12:54.021607Z",
     "iopub.status.busy": "2026-08-16T20:12:54.021496Z",
     "iopub.status.idle": "2026-08-16T20:12:54.038645Z",
     "shell.execute_reply": "2026-08-16T20:12:54.037762Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    "chisla = [3, 8, 12, 5, 16, 9, 20]\n",
    "chetnye_count = 0\n",
    "for n in chisla:\n",
    "    if n % 2 == 0:\n",
    "        chetnye_count += 1\n",
    "print(chetnye_count)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "24a210ea",
   "metadata": {},
   "source": [
    "## Zadanie ★★ - Napraw błąd nr 2 (off-by-one)\n",
    "\n",
    "Trzeba zebrać liczby od 1 do 10 włącznie w lista `chisla_1_do_10`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "41174c26",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:12:54.039834Z",
     "iopub.status.busy": "2026-08-16T20:12:54.039712Z",
     "iopub.status.idle": "2026-08-16T20:12:54.041962Z",
     "shell.execute_reply": "2026-08-16T20:12:54.041542Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"
     ]
    }
   ],
   "source": [
    "chisla_1_do_10 = []\n",
    "for n in range(1, 11):\n",
    "    chisla_1_do_10.append(n)\n",
    "print(chisla_1_do_10)"
   ]
  }
 ],
 "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
}
