Matt's Blog: while { coding }

The Cat In the Hat

September 26th, 2009 Posted in How I Code, programming, programming languages

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] 

Post a Comment