{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "512ac5c9",
   "metadata": {},
   "source": [
    "# 12-19 · Проверка пароля\n",
    "\n",
    "Практика к разделу [«Проекты: консоль команд и проверка пароля»](../../site/chapters/glava-12/12-18-konsol-i-validator.html#validator-parolya)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4616c996",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Накопление состояния через булевы флаги при переборе строки посимвольно."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ae4266c7",
   "metadata": {},
   "source": [
    "## Это учебное упражнение по строкам\n",
    "\n",
    "Не полноценная политика безопасности паролей — тренировка работы со строками и булевыми\n",
    "флагами."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "223a6150",
   "metadata": {},
   "source": [
    "## Про input() в этом ноутбуке\n",
    "\n",
    "Этот ноутбук выполняется автоматически, поэтому `input()` временно подменён на заранее заготовленные ответы."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2186de67",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:38:51.137360Z",
     "iopub.status.busy": "2026-08-17T16:38:51.137204Z",
     "iopub.status.idle": "2026-08-17T16:38:51.160577Z",
     "shell.execute_reply": "2026-08-17T16:38:51.160086Z"
    }
   },
   "outputs": [],
   "source": [
    "_answers = iter(['Python3Code'])\n",
    "\n",
    "def input(prompt=\"\"):\n",
    "    answer = next(_answers)\n",
    "    print(prompt + answer)\n",
    "    return answer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "312ab0a4",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "44fac40f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:38:51.161750Z",
     "iopub.status.busy": "2026-08-17T16:38:51.161638Z",
     "iopub.status.idle": "2026-08-17T16:38:51.164309Z",
     "shell.execute_reply": "2026-08-17T16:38:51.163969Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Придумайте пароль: Python3Code\n",
      "Подходит: True\n"
     ]
    }
   ],
   "source": [
    "password = input(\"Придумайте пароль: \")\n",
    "\n",
    "has_digit = False\n",
    "has_letter = False\n",
    "has_space = False\n",
    "\n",
    "for ch in password:\n",
    "    if ch.isdigit():\n",
    "        has_digit = True\n",
    "    elif ch.isalpha():\n",
    "        has_letter = True\n",
    "    elif ch == \" \":\n",
    "        has_space = True\n",
    "\n",
    "dlinnyj_dostatochno = len(password) >= 8\n",
    "podhodit = dlinnyj_dostatochno and has_digit and has_letter and not has_space\n",
    "\n",
    "print(\"Подходит:\", podhodit)"
   ]
  }
 ],
 "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
}
