---
title: "Challenge #1: Modify a table data"
description: "Python coding challenge: normalize table row lengths by filling missing labels with null values."
url: https://hayorov.me/posts/for-all-rows/
markdown_url: https://hayorov.me/posts/for-all-rows/index.md
json_url: https://hayorov.me/posts/for-all-rows/index.json
type: article
author: Alex Khaerov
author_url: https://hayorov.me/
date: 2020-05-02
lastmod: 2026-04-14
tags: ["python","coding-challenge"]
language: en
word_count: 108
---

# Challenge #1: Modify a table data

> Python coding challenge: normalize table row lengths by filling missing labels with null values.

> 🧩 Challenge: Normalize table row lengths
> 🐍 Language: Python

## 📋 Problem

Given a structure that represents a data table:

```python
[
 [foo:42, baz:7],
 [foo:45, bar:8, baz:9],
]
```

N rows, M items in a row, an item is `<label>:<value>`

Return a new structure with null values for items with no label — ensuring constant row length.

## ✅ Expected Output

```python
[
    [foo:42, bar:7, baz:null],
    [foo:45, bar:8, baz:9],
]
```

## 🔁 Edge Case: Repeating Labels

Labels can repeat arbitrarily:

```python
[
    [foo:42, foo:99, bar:7, foo:77],
    [foo:45, baz:9, baz:9, bar:8, baz:9, baz:10],
]
```

The order of labels in the output can be arbitrary.

## ⚠️ Limitations

N < 10^6, M < 10^6

---

Canonical HTML page: https://hayorov.me/posts/for-all-rows/
Structured JSON: https://hayorov.me/posts/for-all-rows/index.json
Site index for AI agents: https://hayorov.me/llms.txt
