← Back to challenges

Return a List of Sublists

PythonHardarraysloopsdata_structureslanguage_fundamentals

Instructions

Write a function that takes three arguments (x, y, z) and returns a list containing x sublists (e.g. [[], [], []]), each containing y number of item z.

  • x Number of sublists contained within the main list.
  • y Number of items contained within each sublist.
  • z Item contained within each sublist.

Examples

matrix(3, 2, 3) ➞ [[3, 3], [3, 3], [3, 3]]

matrix(2, 1, "innokodakademija") ➞ [["innokodakademija"], ["innokodakademija"]]

matrix(3, 2, 0) ➞ [[0, 0], [0, 0], [0, 0]]

Notes

  • The first two arguments will always be integers.
  • The third argument is either a string or an integer.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: The DECIMATOR