{"id":379643,"date":"2024-06-25T03:19:15","date_gmt":"2024-06-25T03:19:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=379643"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=379643","title":{"rendered":"<span>\u0421\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u0430\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u0432 Python<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0418\u043d\u043e\u0433\u0434\u0430, \u0438\u0437\u0443\u0447\u0430\u044f Python, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0442\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0449\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u041a \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0432\u0435\u0449\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u0443\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>~<\/code>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c <strong>\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u0443\u044e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044e <\/strong>\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u0434 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0442\u044c \u0435\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u0445\u043e\u0434 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430.<\/p>\n<h2>\u0418\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>\u0412 \u044f\u0437\u044b\u043a\u0435 Python \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439. \u041c\u044b \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438\u00a0<strong>\u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430<\/strong>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u0443\u043b\u044f. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>0<\/code>, \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>1<\/code> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>i<\/code>-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <strong>\u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430<\/strong> \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>i - 1<\/code>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/87c\/bae\/c1e\/87cbaec1e8f62399a5bb488fcb1be873.png\" width=\"1765\" height=\"332\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/87c\/bae\/c1e\/87cbaec1e8f62399a5bb488fcb1be873.png\"\/><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">s = '\u041f\u041e\u041a\u041e\u041b\u0415\u041d\u0418\u0415'  print(s[0])       # \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 print(s[1])       # \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438  print(s[7])       # \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 print(s[8])       # \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438<\/code><\/pre>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442:<\/p>\n<pre><code class=\"markdown\">\u041f \u041e \u0418 \u0415<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043d\u0443\u043b\u044f, \u0430 \u043d\u0435 \u0441 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u043c\u0435\u043d\u044c\u0448\u0438\u0439, \u0447\u0435\u043c \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438\u00a0<strong>\u043e\u0442 \u043a\u043e\u043d\u0446\u0430<\/strong>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <code>-1<\/code>. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 (\u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u043a\u043e\u043d\u0446\u0430) \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>-1<\/code>, \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 (\u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u043a\u043e\u043d\u0446\u0430) \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>-2<\/code> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>i<\/code>-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <strong>\u043e\u0442 \u043a\u043e\u043d\u0446\u0430<\/strong> \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>-i<\/code>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c6e\/830\/d91\/c6e830d9178eb59832d5c3eea784cdae.png\" width=\"1756\" height=\"381\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c6e\/830\/d91\/c6e830d9178eb59832d5c3eea784cdae.png\"\/><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">s = '\u041f\u041e\u041a\u041e\u041b\u0415\u041d\u0418\u0415'  print(s[-1])   # \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 print(s[-2])   # \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 print(s[-3])   # \u043f\u0440\u0435\u0434\u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438<\/code><\/pre>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442:<\/p>\n<pre><code class=\"markdown\">\u0415 \u0418 \u041d<\/code><\/pre>\n<h2>\u0421\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u0430\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 ~<\/h2>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0432 Python \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043e\u0442 \u043a\u043e\u043d\u0446\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>0<\/code> \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>-1<\/code> \u043e\u0442 \u043a\u043e\u043d\u0446\u0430, \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>1<\/code> \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>-2<\/code> \u043e\u0442 \u043a\u043e\u043d\u0446\u0430 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8e9\/557\/cc7\/8e9557cc73f60dd814125a1d4c64971a.png\" width=\"1752\" height=\"391\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8e9\/557\/cc7\/8e9557cc73f60dd814125a1d4c64971a.png\"\/><\/figure>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><strong>\u0418\u043d\u0434\u0435\u043a\u0441 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>\u0418\u043d\u0434\u0435\u043a\u0441 \u043e\u0442 \u043a\u043e\u043d\u0446\u0430<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>0<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-1<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>1<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-2<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>2<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-3<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>3<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-4<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>4<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-5<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>5<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-6<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>...<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>...<\/code><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>i<\/code> \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>-(i + 1)<\/code> \u043e\u0442 \u043a\u043e\u043d\u0446\u0430.<\/p>\n<p>\u041d\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442, \u043d\u043e \u0432\u00a0Python <strong>\u0434\u043b\u044f \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b<\/strong> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u0438\u00a0<code>~<\/code>. \u0414\u0430\u043d\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#171;\u043f\u0435\u0440\u0435\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442&#187; \u0431\u0438\u0442\u044b \u0432 <strong>\u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c<\/strong> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u043d\u0438\u044f: <code>1<\/code> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 <code>0<\/code>, \u0430 <code>0<\/code> \u2014 \u0432 <code>1<\/code>.<\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>~<\/code> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e <code>n<\/code> \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\sim n = -(n + 1)\" alt=\"\\sim n = -(n + 1)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/afc\/229\/304\/afc2293041f373b81799ace67625f4b2.svg\" width=\"132\" height=\"22\"\/><\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043e \u0441\u0434\u0432\u0438\u0433\u043e\u043c \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">print(~0) print(~1) print(~2) print(~3)  print(~-1) print(~-2) print(~-3) print(~-4)<\/code><\/pre>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442:<\/p>\n<pre><code class=\"markdown\">-1 -2 -3 -4 0 1 2 3<\/code><\/pre>\n<p>\u041d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u0443\u044e \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044e\u00a0<code>~<\/code>\u00a0\u0434\u043b\u044f \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>is_palindrome()<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0443\u044e \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u0443\u044e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>~<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u043f\u0430\u043b\u0438\u043d\u0434\u0440\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">def is_palindrome(s: str) -> bool:         for i in range(len(s) \/\/ 2):                 if s[i] != s[~i]:                         return False         return True   print(is_palindrome('abccba')) print(is_palindrome('abcpba'))<\/code><\/pre>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442:<\/p>\n<pre><code class=\"yaml\">True False<\/code><\/pre>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435<strong> <\/strong><code>s[i] != s[~i]<\/code> \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c <code>s[i] != s[-i - 1]<\/code> \u0438  <code>s[i] != s[len(s) - i - 1]<\/code>, \u043e\u0434\u043d\u0430\u043a\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u043c \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u0438.<strong><\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/strong>\u00a0\u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u044b \u043d\u0435\u0447\u0430\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u00a0<code>~<\/code>\u00a0\u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0437\u043d\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043b\u0438\u0448\u043d\u0438\u043c.<\/p>\n<p>\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a \u043d\u0430\u0448\u0435\u043c\u0443\u00a0<a href=\"https:\/\/t.me\/pygen_ru\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b\u0443<\/a>, \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438 \u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e!<\/p>\n<p>\u2764\ufe0fHappy Pythoning!?<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/818479\/\"> https:\/\/habr.com\/ru\/articles\/818479\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0418\u043d\u043e\u0433\u0434\u0430, \u0438\u0437\u0443\u0447\u0430\u044f Python, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0442\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0449\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u041a \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0432\u0435\u0449\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u0443\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>~<\/code>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c <strong>\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u0443\u044e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044e <\/strong>\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u0434 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0442\u044c \u0435\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u0445\u043e\u0434 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430.<\/p>\n<h2>\u0418\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>\u0412 \u044f\u0437\u044b\u043a\u0435 Python \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439. \u041c\u044b \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438\u00a0<strong>\u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430<\/strong>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u0443\u043b\u044f. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>0<\/code>, \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>1<\/code> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>i<\/code>-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <strong>\u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430<\/strong> \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>i - 1<\/code>.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">s = '\u041f\u041e\u041a\u041e\u041b\u0415\u041d\u0418\u0415'  print(s[0])       # \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 print(s[1])       # \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438  print(s[7])       # \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 print(s[8])       # \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438<\/code><\/pre>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442:<\/p>\n<pre><code class=\"markdown\">\u041f \u041e \u0418 \u0415<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043d\u0443\u043b\u044f, \u0430 \u043d\u0435 \u0441 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u043c\u0435\u043d\u044c\u0448\u0438\u0439, \u0447\u0435\u043c \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438\u00a0<strong>\u043e\u0442 \u043a\u043e\u043d\u0446\u0430<\/strong>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <code>-1<\/code>. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 (\u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u043a\u043e\u043d\u0446\u0430) \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>-1<\/code>, \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 (\u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u043a\u043e\u043d\u0446\u0430) \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>-2<\/code> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>i<\/code>-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <strong>\u043e\u0442 \u043a\u043e\u043d\u0446\u0430<\/strong> \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>-i<\/code>.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">s = '\u041f\u041e\u041a\u041e\u041b\u0415\u041d\u0418\u0415'  print(s[-1])   # \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 print(s[-2])   # \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 print(s[-3])   # \u043f\u0440\u0435\u0434\u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438<\/code><\/pre>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442:<\/p>\n<pre><code class=\"markdown\">\u0415 \u0418 \u041d<\/code><\/pre>\n<h2>\u0421\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u0430\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 ~<\/h2>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0432 Python \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043e\u0442 \u043a\u043e\u043d\u0446\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>0<\/code> \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>-1<\/code> \u043e\u0442 \u043a\u043e\u043d\u0446\u0430, \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>1<\/code> \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>-2<\/code> \u043e\u0442 \u043a\u043e\u043d\u0446\u0430 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><strong>\u0418\u043d\u0434\u0435\u043a\u0441 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>\u0418\u043d\u0434\u0435\u043a\u0441 \u043e\u0442 \u043a\u043e\u043d\u0446\u0430<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>0<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-1<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>1<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-2<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>2<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-3<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>3<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-4<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>4<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-5<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>5<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>-6<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"335\" width=\"335\">\n<p align=\"center\"><code>...<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>...<\/code><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>i<\/code> \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>-(i + 1)<\/code> \u043e\u0442 \u043a\u043e\u043d\u0446\u0430.<\/p>\n<p>\u041d\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442, \u043d\u043e \u0432\u00a0Python <strong>\u0434\u043b\u044f \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b<\/strong> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u0438\u00a0<code>~<\/code>. \u0414\u0430\u043d\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#171;\u043f\u0435\u0440\u0435\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442&#187; \u0431\u0438\u0442\u044b \u0432 <strong>\u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c<\/strong> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u043d\u0438\u044f: <code>1<\/code> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 <code>0<\/code>, \u0430 <code>0<\/code> \u2014 \u0432 <code>1<\/code>.<\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>~<\/code> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e <code>n<\/code> \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c:<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043e \u0441\u0434\u0432\u0438\u0433\u043e\u043c \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">print(~0) print(~1) print(~2) print(~3)  print(~-1) print(~-2) print(~-3) print(~-4)<\/code><\/pre>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442:<\/p>\n<pre><code class=\"markdown\">-1 -2 -3 -4 0 1 2 3<\/code><\/pre>\n<p>\u041d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u0443\u044e \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044e\u00a0<code>~<\/code>\u00a0\u0434\u043b\u044f \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>is_palindrome()<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0443\u044e \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u0443\u044e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>~<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u043f\u0430\u043b\u0438\u043d\u0434\u0440\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">def is_palindrome(s: str) -> bool:         for i in range(len(s) \/\/ 2):                 if s[i] != s[~i]:                         return False         return True   print(is_palindrome('abccba')) print(is_palindrome('abcpba'))<\/code><\/pre>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442:<\/p>\n<pre><code class=\"yaml\">True False<\/code><\/pre>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435<strong> <\/strong><code>s[i] != s[~i]<\/code> \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c <code>s[i] != s[-i - 1]<\/code> \u0438  <code>s[i] != s[len(s) - i - 1]<\/code>, \u043e\u0434\u043d\u0430\u043a\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u043c \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u0438.<strong><\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/strong>\u00a0\u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u044b \u043d\u0435\u0447\u0430\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u00a0<code>~<\/code>\u00a0\u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0437\u043d\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043b\u0438\u0448\u043d\u0438\u043c.<\/p>\n<p>\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a \u043d\u0430\u0448\u0435\u043c\u0443\u00a0<a href=\"https:\/\/t.me\/pygen_ru\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b\u0443<\/a>, \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438 \u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e!<\/p>\n<p>\u2764\ufe0fHappy Pythoning!?<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/818479\/\"> https:\/\/habr.com\/ru\/articles\/818479\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-379643","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=379643"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379643\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=379643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=379643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=379643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}