A Comprehensive Guide to List Comprehension in Python

If you’re somewhat comfortable with the basics of Python — data types, strings, lists, dictionaries and all that fun stuff, here’s one trick to take your code to another level — list comprehension. By another level, I mean that your code becomes 1–2 lines shorter and looks cooler :)

List Comprehension in a Nutshell