Ctrl K
Python · Junior · Theory

What's the difference between an iterable and an iterator? How does a for loop work under the hood?

~4 min by voice

How to approach it

This checks whether the candidate understands Python's iteration protocol: who hands out the iterator, who hands out the elements, how the end is signaled, and what the for loop actually does.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsHow is a generator different from a regular iterator, and what actually happens on yield? Tell me about send and yield from — where have you used them? SeniorYou need to process a 20 GB log file: filter the lines and compute some aggregates over them. How would you write that in Python? Mid-level

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~4 min