Lesson guide
What this Python exercise practices
Transform each item in a list is a beginner practice lesson that focuses on lists, iteration, filtering. It is designed to be solved in about 8 minutes with examples, starter code, and test feedback.
Prerequisites
- Python variables
- List values
- Basic indexing
Difficulty and time
- Level
- Beginner
- Estimated time
- 8 minutes
Practice path
Related public exercises
Summary
Apply a simple numeric transformation to each element and return a new list.
Problem statement
Write a function scale_list(nums, factor) that returns a new list where each number from nums is multiplied by factor. The function should not modify the original list. Support integers and floats for values and factor.
Task
Implement a function that multiplies every element in a list by a given factor.
Examples
Multiply by factor
Input
scale_list([1, 2, 3], 2)
Output
[2, 4, 6]
Explanation
Each element is multiplied by 2.
Input format
Two arguments: a list of numbers (ints or floats) and a numeric factor.
Output format
A list of numbers where each input element has been multiplied by the factor.
Constraints
Input list length up to a few thousand. Elements and factor are numeric types (int or float).
Samples
Sample input 0
[] , 5
Sample output 0
[]
Explanation 0
Empty list returns empty list regardless of factor.
AI assistant
Ask me anything!
Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.
Chat history is temporary and will not be saved.
Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.