A Split You Can Repeat

Python for AIMedium+10 XP+10

A Split You Can Repeat

Before training a model, data is split into a training part and a test part. The split is random — but it must come out the same on every run.

Task: write split_data(items, seed) that returns a list [train, test].

  1. Call random.seed(seed) once, at the start.
  2. Go through items in order. For each item, call random.randint(1, 10) exactly once.
  3. If the number is 8 or less, the item goes into train; otherwise it goes into test.
  4. Both lists keep the items in their original order.

Examples

items = ["a", "b", "c", "d", "e"]
seed = 1
returns [['a', 'c', 'd', 'e'], ['b']]
items = []
seed = 5
returns [[], []]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run