# Source: https://upstash.com/docs/redis/sdks/ts/commands/list/lpos.md

# Source: https://upstash.com/docs/redis/sdks/py/commands/list/lpos.md

> ## Documentation Index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# LPOS

> Returns the index of matching elements inside a list.

## Arguments

<ParamField body="key" type="str" required>
  The key of the list.
</ParamField>

<ParamField body="element" type="unknown" required>
  The element to match.
</ParamField>

<ParamField body="rank" type="int">
  Which match to return. 1 to return the first match, 2 to return the second match, and so on.
  1 by default.
</ParamField>

<ParamField body="count" type="int">
  The maximum number of elements to match. If specified, an array of elements
  is returned instead of a single element.
</ParamField>

<ParamField body="maxlen" type="int">
  Limit the number of comparisons to perform.
</ParamField>

## Response

<ResponseField type="int | List[int]" required>
  The index of the matching element or an array of indexes if `count` is
  specified.
</ResponseField>

<RequestExample>
  ```py Example  theme={"system"}
  redis.rpush("key", "a", "b", "c"); 

  assert redis.lpos("key", "b") == 1
  ```

  ```py With Rank  theme={"system"}
  redis.rpush("key", "a", "b", "c", "b"); 

  assert redis.lpos("key", "b", rank=2) == 3
  ```

  ```py With Count theme={"system"}
  redis.rpush("key", "a", "b", "b")

  assert redis.lpos("key", "b", count=2) == [1, 2]
  ```
</RequestExample>