logo

... comprehensions: dict



Notes

There are list comprehensions.

[c for i, c in enumerate('abceabce') if i < 5]

There are set comprehensions.

{c for i, c in enumerate('abceabce')}

There are tuple comprehensions.

tuple(c for i, c in enumerate('abceabce'))

And dictionary comprehensions!

{i: c for i, c in enumerate('abceabce') if i < 5}

Feedback? See an issue? Something unclear? Feel free to mention it here.



If you want to be kept up to date, consider signing up for the newsletter.