A structured lesson workspace with readable content, hands-on examples, and a clean path to completion.
This lesson is a bonus crossover. The video in the original tutorial series includes a Python lesson on enumerate, and it illustrates a contrast that sharpens your C thinking. In Python, for i, val in enumerate(items) gives you the index and the value in one clean iteration. In C, you write for (int i = 0; i < n; i++) and access arr[i] manually. The C version is more verbose but gives you explicit control over the index, the bounds, and the memory access. Understanding both perspectives makes you better at both languages.
fruits = ["apple", "banana", "cherry"]for i, fruit in enumerate(fruits):print(f"{i}: {fruit}")for i, fruit in enumerate(fruits, start=1):print(f"{i}. {fruit}")
#include <stdio.h>int main(void) {const char *fruits[] = {"apple", "banana", "cherry"};int n = 3;for (int i = 0; i < n; i++) {printf("%d: %s\n", i, fruits[i]);}for (int i = 0; i < n; i++) {printf("%d. %s\n", i + 1, fruits[i]);}return 0;}
Same output. The C version requires you to manage the index variable, the bounds check, and the array access separately. The Python version bundles them into enumerate. The C version gives you the ability to modify i inside the loop, to skip elements, to access arr[i-1] and arr[i+1]. The Python version prevents off-by-one errors by construction. Both are correct. The trade-off is control versus safety.
Seeing the same problem solved in two languages sharpens your understanding of both. C gives you the mechanism. Python gives you the policy. Knowing when to want each is the mark of a mature programmer. Next: the course capstone, where everything comes together.
Finish the lesson once you have worked through the material. This awards ★ 10 XP.