Practice Memory Diagram


Snippet

    def column_vals(table: list[dict[str, str]], header: str) -> list[str]:
        """Return a list of all values under a specific header."""
        result: list[str] = []
        for elem in table:
            result.append(elem[header])
        return result


    def columnar(table: list[dict[str, str]]) -> dict[str, list[str]]:
        """Reformat data so it's a dictionary with column headers as keys."""
        result: dict[str, list[str]] = {}
        first_row: dict[str, str] = table[0]
        for key in first_row:
            result[key] = column_vals(table, key)
        return result

    data: list[dict[str, str]] = [{'Comp': '110', 'Bio': '100'}, {'Comp': '210', 'Bio': '200'}]
    columnar(data)

Solution

Accidentally missed id: 2. id:3 should instead be id:2, id:4 should be id:3 and so on. Image Description Here

Image Description

(Coming Soon)

Contributor(s): Alyssa Lytle, Viktorya Hunanyan