• + 0 comments

    I don't disagree with the principle but in this specific case there's absolutely nothing wrong with using a list comprehension instead of a for loop. The comprehension is doing a simple job elegantly.

    If this were production code, I'd use a generator rather than a comprehension, to avoid loading the entire data set into memory unnecessarily, but that's not a problem with the tiny data set here.