convert for-loop to dictionary comprehension