Created
May 25, 2018 18:11
Star
You must be signed in to star a gist
Helpful Python Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# select n items from a dict | |
from itertools import islice | |
def take(n, iterable): | |
"Return first n items of the iterable as a list" | |
return list(islice(iterable, n)) | |
n = 5 | |
for k,v in take(n, dictionary.items()): | |
print(k,v) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment