QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 66

Spot the loop-else misconception: a for loop receives an empty iterable, performs zero passes, and encounters no break. What happens to its attached else suite?

  1. It is skipped because the body never ran.
  2. It runs because no break occurred.Ճիշտ պատասխան
  3. It raises an error because the loop was empty.
  4. It runs only when a break occurs.

Բացատրություն

The else suite runs because the loop finished without executing break; zero passes still count as such a normal finish. Requiring the body to run at least once confuses loop completion with body execution.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 66: Spot the loop-else misconception: a for loop receives an… · Python Fundamentals · Questena