$Python typing practice

Practice typing Python colons, list comprehensions, and f-strings in a function that formats readings above a threshold.

Start practice

Practice example

def format_alerts(readings, limit):
    return [
        f"{name}: {value:.1f}"
        for name, value in readings
        if value >= limit
    ]
):
Finish the function signature with a colon before pressing Enter.
for name, value in readings
Keep the expression, loop, and filter inside one pair of square brackets. The comprehension's filter line ends without a colon.
f"{name}: {value:.1f}"
The first colon becomes text in the output. The colon inside the second pair of braces starts the format specifier.

To type this example, paste it into Your code.