mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Doc: Do not suggest s[::-1]
for reversed order (GH-22457)
(cherry picked from commit fb2e94692e
)
Co-authored-by: Andre Delfino <adelfino@gmail.com>
This commit is contained in:
parent
f72101bb62
commit
03bfb07937
2 changed files with 1 additions and 7 deletions
|
@ -1116,7 +1116,7 @@ trailing newline from a string.
|
|||
How do I iterate over a sequence in reverse order?
|
||||
--------------------------------------------------
|
||||
|
||||
Use the :func:`reversed` built-in function, which is new in Python 2.4::
|
||||
Use the :func:`reversed` built-in function::
|
||||
|
||||
for x in reversed(sequence):
|
||||
... # do something with x ...
|
||||
|
@ -1124,11 +1124,6 @@ Use the :func:`reversed` built-in function, which is new in Python 2.4::
|
|||
This won't touch your original sequence, but build a new copy with reversed
|
||||
order to iterate over.
|
||||
|
||||
With Python 2.3, you can use an extended slice syntax::
|
||||
|
||||
for x in sequence[::-1]:
|
||||
... # do something with x ...
|
||||
|
||||
|
||||
How do you remove duplicates from a list?
|
||||
-----------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue