Use enumerate:

In [3]: user_details = [{'name':x, 'rank':i} for i,x in enumerate(ranked_users)] 

In [4]: user_details
Out[4]: 
[{'name': 'jon', 'rank': 0},
 {'name': 'bob', 'rank': 1},
 {'name': 'jane', 'rank': 2},
 {'name': 'alice', 'rank': 3},
 {'name': 'chris', 'rank': 4}]

PS. My first answer was

user_details = map(lambda (i,x): {'name':x, 'rank':i}, enumerate(ranked_users))

I'd strongly recommend using a list comprehension or generator expression over map and lambda whenever possible. List comprehensions are more readable, and tend to be faster to boot.

Answer from unutbu on Stack Overflow
🌐
GitHub
github.com › aws-samples › amazon-opensearch-batch-indexing-with-aws-lambda
GitHub - aws-samples/amazon-opensearch-batch-indexing-with-aws-lambda · GitHub
This repository provides guidance on how to use the Amazon OpenSearch Python client to perform batch operations using Lambda functions and how to architect your solution using a data lake architecture.
Starred by 14 users
Forked by 2 users
Languages   Python
Discussions

[aws-lambda-python] Unify `entry` field betwen aws-lambda-nodejs and aws-lambda-python
I love the new PythonFunction support in aws-cdk! I did, however, notice a difference between how the entry property works between aws-lambda-nodejs and aws-lambda-python. In aws-lambda-nodejs, the entry field is a fully qualified path to the index file. More on github.com
🌐 github.com
10
August 7, 2020
python - Return the index of the first element of a list which makes a passed function true - Stack Overflow
Not one single function, but you can do it pretty easily in Python 2: Copy>>> test = lambda c: c == 'x' >>> data = ['a', 'b', 'c', 'x', 'y', 'z', 'x'] >>> map(test, data).index(True) 3 · If you don't want to evaluate the entire list at once you can use itertools, but it's not as pretty: More on stackoverflow.com
🌐 stackoverflow.com
python - How to use git with lambda function - Stack Overflow
I am trying to import the git library needed to clone the repo from gitlab. A lot of research suggested that the best way would be to add a layer to the lambda function. So, I created a lambda laye... More on stackoverflow.com
🌐 stackoverflow.com
indexing - How to make an index static for a python lambda expression - Stack Overflow
Find centralized, trusted content ... you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... The result is 6, I would expect the result to be 1. How can I make the index inside the lambda expression static without writing t[1]+1, i.e. using a variable? ... Python's closures ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › run-llama › llama_index
GitHub - run-llama/llama_index: LlamaIndex is the leading document agent and OCR platform · GitHub
May 30, 2026 - Customized: llama-index-core. Install core LlamaIndex and add your chosen LlamaIndex integration packages on LlamaHub that are required for your application. There are over 300 LlamaIndex integration packages that work seamlessly with core, allowing you to build with your preferred LLM, embedding, and vector store providers. The LlamaIndex Python library is namespaced such that import statements which include core imply that the core package is being used.
Starred by 50.9K users
Forked by 7.8K users
Languages   Python 72.4% | Jupyter Notebook 25.0% | Makefile 1.9% | JavaScript 0.4% | HTML 0.3% | Shell 0.0%
🌐
GitHub
github.com › aws › aws-cdk › issues › 9518
[aws-lambda-python] Unify `entry` field betwen aws-lambda-nodejs and aws-lambda-python · Issue #9518 · aws/aws-cdk
August 7, 2020 - I fixed the problem by using entry and index like this: new PythonFunction(this, 'MyFunc', { entry: path.join(__dirname, 'lambda'), index: 'my_lambda.py', }
Author   aws
🌐
Stack Overflow
stackoverflow.com › questions › 76376898 › how-to-use-git-with-lambda-function
python - How to use git with lambda function - Stack Overflow
CMD [ "index.handler" ] Your lambda code will be called index.py · import shutil from git import Repo from aws_lambda_powertools import Logger logger = Logger() REPOSITORY_URL = "https://github.com/gitpython-developers/QuickStartTutorialFiles.git" ...
🌐
GitHub
github.com › nficano › python-lambda
GitHub - nficano/python-lambda: A toolkit for developing and deploying serverless Python code in AWS Lambda. · GitHub
A toolkit for developing and deploying serverless Python code in AWS Lambda. - GitHub - nficano/python-lambda: A toolkit for developing and deploying serverless Python code in AWS Lambda.
Starred by 1.5K users
Forked by 225 users
Languages   Python 97.3% | Makefile 2.7%
Find elsewhere
🌐
w3resource
w3resource.com › python-exercises › lambda › python-lambda-exercise-46.php
Python: Find all index positions of the maximum and minimum values in a given list using lambda - w3resource
July 12, 2025 - # Define a function 'position_max_min' ... specifies a lambda function to evaluate each element by its value max_result = max(enumerate(nums), key=(lambda x: x[1])) # Find the minimum value and its index in 'nums' using 'min' function ...
🌐
GitHub
gist.github.com › shanealynn › b34acd07fdaba4f220f4e03c6f902a9f
Pandas index - loc selection examples.py · GitHub
Save shanealynn/b34acd07fdaba4f220f4e03c6f902a9f to your computer and use it in GitHub Desktop.
🌐
GitHub
github.com › dry-python › lambdas
GitHub - dry-python/lambdas: Write short and fully-typed lambdas where you need them. · GitHub
>>> from lambdas import _ >>> scores = [ ... {'name': 'Nikita', 'score': 2}, ... {'name': 'Oleg', 'score': 1}, ... {'name': 'Pavel', 'score': 4}, ... ] >>> print(sorted(scores, key=_['score'])) [{'name': 'Oleg', 'score': 1}, {'name': 'Nikita', ...
Starred by 285 users
Forked by 6 users
Languages   Python
🌐
GitHub
github.com › cloudreach › aws-lambda-es-cleanup
GitHub - cloudreach/aws-lambda-es-cleanup: AWS Elasticsearch Lambda Curator
Using AWS environment variable you can easily modify the behaviour of the Lambda function ... Index/indices to process comma separated, with all every index will be processed except the one listed in skip_index
Starred by 114 users
Forked by 64 users
Languages   HCL 59.5% | Python 36.1% | Shell 4.4% | HCL 59.5% | Python 36.1% | Shell 4.4%
🌐
StrataScratch
stratascratch.com › blog › how-to-use-python-lambda-functions
How to Use Python Lambda Functions - StrataScratch
December 7, 2023 - In our study of urbanization trends with global socio-economic and demographic data, we've created a special metric: the 'Urbanization Index.' We calculate this index by using Python lambda functions with the apply() method.
🌐
GitHub
gist.github.com › alexcasalboni › 2ca4767a70a557fae377544b6cd44369
AWS ALB - AWS Lambda handler (Python) · GitHub
Save alexcasalboni/2ca4767a70a557fae377544b6cd44369 to your computer and use it in GitHub Desktop. Download ZIP · AWS ALB - AWS Lambda handler (Python) Raw · index.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
GitHub
github.com › grantcooksey › aws-lambda-python-examples
GitHub - grantcooksey/aws-lambda-python-examples: Lessons and examples to get started using aws lambda function in python · GitHub
This repo serves as a starting point for building reliable aws lambda functions in python. These examples are focused on not only teaching the basics, but providing examples of common use cases, and discusses the developer workflow that I have learned to use.
Starred by 61 users
Forked by 41 users
🌐
GitHub
github.com › abiydv › index-elasticsearch
GitHub - abiydv/index-elasticsearch: Lambda to bulk index documents to Elasticsearch · GitHub
Lambda to bulk index documents to Elasticsearch. Contribute to abiydv/index-elasticsearch development by creating an account on GitHub.
Author   abiydv
🌐
GitHub
github.com › topics › python-lambda
python-lambda · GitHub Topics · GitHub
visualization graph animation numpy sklearn python-library plotly python3 matplotlib python-3 3d 3d-graphics python-lambda python-app ... A list of hopefully useful AWS lambdas and lambda-related resources.
🌐
Bobby Hadz
bobbyhadz.com › blog › python-map-with-index
Get access to the Index in the map() function in Python | bobbyhadz
Copied!my_list = ['apple', 'banana', 'melon'] for index, item in enumerate(my_list): print(index, item) # 👉️ 0 apple, 1 banana, 2 melon · Notice that we had to unpack the elements of the tuple. ... This might not suit your use case (especially if using a one-liner lambda function).
🌐
HackMD
hackmd.io › @tsungtang › By5gmOF04
python lambda, reduce map and filter - HackMD
使用for迴圈 ```python= [index for index, ele in enumerate([1, 2, 1]) if ele == 1] ``` ![](https://i.imgur.com/qjxcOxg.png) [Data Structures > More on Lists](https://docs.python.org/2/tutorial/datastructures.html#more-on-lists) <br/> ## ```reduce()``` Format: reduce(function, sequence) 必須傳入一個binary function(具有兩個參數的函式),最後僅會回傳單一值。 reduce會依序先取出兩個元素,套入function作用後的回傳值再與List中的下一個元素一同作為參數,以此類推,直到List所有元素都被取完。 ```python= # Import reduce from fun