Matt's Blog: while { coding }
    Back to Matt's Homepage   |   Hire Matt

The Cat In the Hat

I continue to be impressed by the flexibility of list comprehensions, especially in Python. The other day I discovered that I could handle a small but twisty problem quite simply, which I will now share in the style of Dr. Seuss:


[hat[cat] if cat in hat else cat for cat in cats]