redis.rpush("mylist", "one", "two", "three")

assert redis.ltrim("mylist", 0, 1) == True

assert redis.lrange("mylist", 0, -1) == ["one", "two"]

Arguments

key
str
required

The key of the list.

start
int
required

The index of the first element to keep.

stop
int
required

The index of the first element to keep.

Response

Returns True if the list was trimmed, False otherwise.

redis.rpush("mylist", "one", "two", "three")

assert redis.ltrim("mylist", 0, 1) == True

assert redis.lrange("mylist", 0, -1) == ["one", "two"]