Back to Lesson
Complex Transformation
Apply function modifications during list comprehensions over structured objects.
Instructions
- Given.
logs = ["ERROR: failed", "INFO: running", "ERROR: crash"] - We only want logs representing errors. Also, we want to strip the "ERROR: " identifier prefix.
- Use a list comprehension that utilizes a condition (starts with "ERROR") and immediately transforms the matching string (by slicing the leading 7 characters). Print the subset.
main.py
main.py
Ctrl + Enter