Challenge 1
Combine the inner lists into one stream and print the names in their original order.
from itertools import chain
teams = [["Iris", "Omar"], ["Bo"]]
names = list()
print(names)
Press Ctrl⌘Enter to check your answer
Practice flattening, limiting, batching, grouping consecutive records, and building combinations with itertools.
Challenge 1
from itertools import chain
teams = [["Iris", "Omar"], ["Bo"]]
names = list()
print(names)
Press Ctrl⌘Enter to check your answer
Challenge 2
from itertools import count, islice
values = list()
print(values)
Press Ctrl⌘Enter to check your answer
Challenge 3
from itertools import accumulate
values = [4, 1, 7, 2]
result = list()
print(result)
Press Ctrl⌘Enter to check your answer
Challenge 4
from itertools import combinations
people = ["Mia", "Leo", "Ari"]
teams = list()
print(teams)
Press Ctrl⌘Enter to check your answer
Challenge 5
from itertools import groupby
from operator import itemgetter
records = [("design", "Amina"), ("design", "Leo"), ("support", "Omar"), ("support", "Maya")]
for department, entries in :
names = [name for _, name in entries]
print(f"{department}: {', '.join(names)}")
Press Ctrl⌘Enter to check your answer