Medium
Refactor Inefficient Python Loop
Optimize a slow Python loop by using better data structures or built-in libraries.
📝 Prompt Inhoud
Review the following Python code snippet that processes a list of user dictionaries to find users over the age of 18. The current implementation uses a nested for-loop which is slow. Rewrite the code using list comprehensions or the 'filter' function to make it more Pythonic and efficient. Original code: results = []; for user in users: if user['age'] > 18: results.append(user)