Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

For loop help?

Asked by 9 years ago

I was wondering why putting a for loop inside another loop doesn't work as expedited?

Example of what I mean

Output

a : 10 b : 5 c : 2

a : 7 b : 5 c : 2`

a : 4 b : 5 c : 2

a : 1 b : 5 c : 2

Script:

for a = 10,1,-3 do
        b = 5,1,-2 -- a =
            c = 2,1,-1
    print("a : "..a.." b : "..b.." c : "..c)
end

Why does this happen?

1 answer

Log in to vote
1
Answered by 9 years ago

You didn't actually put another loop inside at all. You merely initiated variables and declared them

Here is a fix:

for a = 10,1,-3 do
     for b = 5,1,-2
          for c = 2,1,-1
             print("a : "..a.." b : "..b.." c : "..c)
         end
   end
end

0
Lol my bad kevinnight45 550 — 9y
Ad

Answer this question