← Quiz: API Design: all 15 questions
Quiz: API Design · Question 13 of 15
What does this print? (code)
What does this print?
posts = [9, 8, 7, 6, 5, 4]
after = 7
page = [p for p in posts if p < after][:2]
print(page, page[-1])
- A.[7, 6] 6
- B.[8, 9] 9
- C.[6, 5] 6
- D.[6, 5] 5
Answer & explanation
Correct answer: [6, 5] 5
The cursor asks for items older than 7; the last item, 5, becomes the next cursor.
Can you get the rest right without peeking?
Take the timed Quiz: API Design quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →