← Back to challenges

Multiply by Length

PythonHardarraysalgorithmsmathloops

Instructions

Create a function to multiply all of the values in a list by the amount of values in the given list.

Examples

multiply_by_length([2, 3, 1, 0]) ➞ [8, 12, 4, 0]

multiply_by_length([4, 1, 1]) ➞ ([12, 3, 3])

multiply_by_length([1, 0, 3, 3, 7, 2, 1]) ➞  [7, 0, 21, 21, 49, 14, 7]

multiply_by_length([0]) ➞ ([0])

Notes

  • All of the values given are numbers.
  • All lists will have at least one element.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Not Not Not True