From 0f5e7cd9e44b04d47b298b2f28a1652c729a4784 Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Mon, 21 Jan 2013 18:55:29 +0200 Subject: [PATCH] explained for - else --- common/lib/capa/capa/verifiers/draganddrop.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/lib/capa/capa/verifiers/draganddrop.py b/common/lib/capa/capa/verifiers/draganddrop.py index 906b9ffb7e..b1072507d2 100644 --- a/common/lib/capa/capa/verifiers/draganddrop.py +++ b/common/lib/capa/capa/verifiers/draganddrop.py @@ -217,6 +217,13 @@ class DragAndDrop(object): if PositionsCompare(u_el) == PositionsCompare(c_el): break else: + # General: the else is executed after the for, + # only if the for terminates normally (not by a break) + + # In this case, 'for' is terminated normally if every element + # from 'correct' list isn't equal to concrete element from + # 'user' list. So as we found one element from 'user' list, + # that not in 'correct' list - we return False return False if flag == 'unordered_equal': @@ -229,6 +236,8 @@ class DragAndDrop(object): temp.remove(c_el) break else: + # same as upper - if we found element from 'user' list, + # that not in 'correct' list - we return False. return False return True