Use itertools.islice
:
list(itertools.islice(it, n))
More Related Contents:
- Is there a way to ordinate numbers in a list?
- finding the biggest sequence of repeating numbers in a list
- How to append new line to the list
- Remove duplicate dict in list in Python
- How to efficiently compare two unordered lists (not sets) in Python?
- Negative list index? [duplicate]
- list to dictionary conversion with multiple values per key?
- How do I build a numpy array from a generator?
- Python – TypeError: ‘int’ object is not iterable
- Appending a dictionary to a list – I see a pointer like behavior
- Appending item to lists within a list comprehension
- Why doesn’t list have safe “get” method like dictionary?
- Does python have a sorted list?
- Summing elements in a list
- How to write a generator class?
- Tuple unpacking order changes values assigned
- Convert string to list. Python [string.split() acting weird]
- How do you split reading a large csv file into evenly-sized chunks in Python?
- Make dictionary from list with python [duplicate]
- Find the index of an item in a list of lists
- Replacing a sublist with another sublist in python
- What’s the difference between plus and append in python for list manipulation? [duplicate]
- Union find implementation using Python
- Assign multiple values of a list
- Deleting consonants from a string in Python
- Counting depth or the deepest level a nested list goes to
- Which is the most efficient way to iterate through a list in python?
- How does str.startswith really work?
- Best way to remove elements from a list
- All possible permutations of a set of lists in Python