On this page
  1. next
  2. Import & Availability
  3. Overview & Signature
  4. Usage
  5. Gotchas
  6. REPL Inspect

next

Prev: min | Up: __builtins__ | Next: object
Rel: all, any, enumerate, filter, iter
Ref: docs.python.org — next
Tags: #public #python3 #builtins


Import & Availability

# Built-in (available globally without import)
from builtins import next

Overview & Signature

next(iterator[, default])

Return the next item from the iterator. If default is given and the iterator is exhausted, it is returned instead of raising StopIteration.

Usage

it = iter([10, 20])
assert next(it) == 10
assert next(it) == 20
assert next(it, "done") == "done"

Gotchas

REPL Inspect

help(next)

Linked from

Related notes