> ## Documentation index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Ask it with GET https://upstash.com/docs/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://upstash.com/docs/common/help/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://upstash.com/docs/feedback?path=/docs/redis/sdks/py/commands/list/lpos&helpful=true` (or `false`) records whether this page helped. An optional `comment` (URL-encoded, at most 500 characters) says what was missing or wrong. It is anonymous and needs no key. Comments hold no code, secrets or personal data.

# 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 
redis.rpush("key", "a", "b", "c"); 

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

```py With Rank 
redis.rpush("key", "a", "b", "c", "b"); 

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

```py With Count
redis.rpush("key", "a", "b", "b")

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

</RequestExample>
