#29
List Comprehension Conversion
EASYArrayPYTHON
Problem Description
A data transformation job needs to normalize a sequence of integer indices into half-unit float values for downstream processing — a common pattern in feature engineering and ETL pipelines.
A `for` loop iterates over `range(n)` and appends each value divided by `2` to a list. **Rewrite this logic as a single list comprehension** that produces the same result.
Given an integer `n`, return a list where each element at index `i` is `i / 2` for all `i` in `range(n)`.
Topics
arraylist comprehension
Asked at Companies
paypal
Solve This Problem
Sign up to access the interactive code editor, run test cases, view the editorial, and get AI-powered feedback on your solution.
Start Solving →