Operator Functions
operator.length_hint()
Obtain len(obj) if supported, otherwise a nonnegative estimate from __length_hint__, otherwise default. The estimate need not equal actual iteration length.
Formal Syntax & Structure
python syntaxpython
operator.length_hint(obj, default=0, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| obj | object | Object to inspect or copy. |
| default | int | Nonnegative integer fallback estimate; used when neither length nor hint is available. |
Return Value
int
The int result described above.
Working Example
Example Snippetpython
import operatorit=iter([1,2,3])next(it)print(operator.length_hint(it))