← Quiz: itertools and functools: all 10 questions
Quiz: itertools and functools · Question 6 of 10
What does this print? (code)
What does this print?
from itertools import groupby
print([k for k, g in groupby("aabba")])
- A.['a', 'b']
- B.['a', 'b', 'a']
- C.['aa', 'bb', 'a']
- D.['a', 'a', 'b', 'b', 'a']
Answer & explanation
Correct answer: ['a', 'b', 'a']
Three runs of consecutive equal letters: aa, bb, a.
Can you get the rest right without peeking?
Take the timed Quiz: itertools and functools quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →