# Understanding string reversal

Предлагаю решить задачу вместе: без спешки, с объяснением каждой строки.

## Задача

Перевернуть строку: из `"python"` получить `"nohtyp"`. Задача-разминка, знакомая каждому новичку.

## Решение

```python
def reverse_string(s: str) -> str:
    return s[::-1]


print(reverse_string("python"))
```

## Как это работает

Срез `[::-1]` проходит строку с конца с шагом -1 и создаёт перевёрнутую копию. Это идиоматичный способ в Python; в других языках тот же результат даёт цикл от конца к началу.

## Пример работы

```text
nohtyp
```

## Сложность

O(n) по времени и памяти.


Такой пример хорошо закрепляется практикой — перепишите решение руками и прогоните на своих тестах.

**Читайте также:**

[памяти](https://gal48877.carrd.co/) · [копию](https://news-ctl-posts.hashnode.dev/common-mistakes-in-minimum-and-maximum-of-a-list-mw77k5ud) · [Задача-разминка](https://contracosta.news/wp-content/uploads/event-manager-uploads/event_banner/2026/11/public-leed-project-directory-606580.pdf) · [Сложность](https://dev.to/devnote2319/account-pools-for-multi-platform-posting-bb4an-4op6) · [Такой](https://dev.to/devnote2319/logging-pipeline-runs-without-noise-0gyva-47m4) · [спешки](https://discuss.tchncs.de/post/65440584) · [своих](https://rentry.org/camvod-375340) · [перепишите](https://paste2.org/6HAGxW70) · [создаёт](https://hey.xyz/posts/27hmsqna7fgkhe94t2r) · [каждому](https://cultmtl.com/wp-content/uploads/event-manager-uploads/event_banner/2026/11/arikystya-09f78c.pdf) · [работает](https://gitlab.com/chuongnhuhoa/trusrewre/-/blob/main/articles/power-tests-mwc6te6w.md) · [проходит](https://gofile.io/d/8F9rYErR) · [конца](https://gall.dcinside.com/mgallery/board/view/?id=thekpop&no=64454) · [началу](https://pastebin.com/mkXAdPqm) · [Предлагаю](https://jaflysilve.freeflarum.com/d/22303-22303-mana-rose-leaked-album-nude-photos-x-rated-content) · [Пример](https://edu-notes-pages.pages.dev/power-tests/) · [хорошо](https://gitlab.com/chuongnhuhoa/trusrewre/-/blob/main/articles/word-count-tests-mwbw4vcx.md) · [строки](https://dev.to/devnote2319/idempotent-publishing-jobs-84uy2-3em1) · [Python](https://dev.to/devnote2319/idempotent-publishing-jobs-6mcdb-10oo) · [идиоматичный](https://jaflysilve.freeflarum.com/d/22288-22288-sude-benli) · [результат](https://dev.to/devnote2319/idempotent-publishing-jobs-oxu5p-1763) · [практикой](https://dev.to/devnote2319/logging-pipeline-runs-without-noise-t8zmn-2f67) · [nohtyp](https://ababesoft.com/as109+%E6%B0%B4%E5%8F%94?f=instapaper) · [строку](https://gofile.io/d/oN0F39OU) · [руками](https://gofile.io/d/f5dT1rtg)

