Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111687 > unrolled thread
| Started by | Michael Selik <michael.selik@gmail.com> |
|---|---|
| First post | 2016-07-20 20:54 -0500 |
| Last post | 2016-07-20 20:54 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: reversed(enumerate(x)) Michael Selik <michael.selik@gmail.com> - 2016-07-20 20:54 -0500
| From | Michael Selik <michael.selik@gmail.com> |
|---|---|
| Date | 2016-07-20 20:54 -0500 |
| Subject | Re: reversed(enumerate(x)) |
| Message-ID | <mailman.12.1469066103.22221.python-list@python.org> |
> On Jul 20, 2016, at 12:42 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>
> for i, n in reversed(enumerate(x)): pass
>
> fails with "TypeError: argument to reversed() must be a sequence".
So make it a sequence:
for i, n in reversed(list(enumerate(x))): pass
If ``x`` is very large, you can use your zip/range technique to save memory.
Back to top | Article view | comp.lang.python
csiph-web