Skip to content

Commit c852cf4

Browse files
committed
Fix for loop
1 parent c1d0547 commit c852cf4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

interpreter.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ def visitElse(self, ctx: MyParser.ElseContext):
4141
def visitForLoop(self, ctx: MyParser.ForLoopContext):
4242
a, b = self.visit(ctx.range_())
4343
variable = ctx.id_().getText()
44-
while a <= b:
45-
self.memory_stack.put(variable, Int(a))
46-
a = a + 1 # to increment enumerateor and disregard changes inside the loop
44+
for i in range(a, b + 1):
45+
self.memory_stack.put(variable, Int(i))
4746
try:
4847
self.visit(ctx.statement())
4948
except Continue:

0 commit comments

Comments
 (0)