Tic Tac Toc game board - HELP

python

#1

why does it only print the " l l l l " once?

I tried setting up a loop, maybe I could have done it more efficient, cuz it didnt work >.<

Any ideas how to solve it?


#2

You are printing all items in verti_line_1 with for loop and you printed them all :slight_smile:
Your for loop is made for looping inside verti_line_1 array and only for that array. When it printed all items from that array out, the loop ends.


#3

But i wrote,
"if i == 6: (6 is the last item in the list)
then it should go onto another line "\n"
and start over verti_line_1
until row = 3 it should stop

How can I fix it to go through the 6 command


#4

That is not how this works :slight_smile:
You set your loop to go over for element in some_array and for loop will only log out elements from that array and not any other else. It won't go to another one or do something you did not tell it to do.
I can understand your logic but that is not how programming logic works.
You could put all that strings from all arrays in 1 array. And then when you loop over it will output every item in that array. It doesn't matter if it is 1 element or 100 of them.


#5

Could u help me, how should I rewrite it probaly to make it loop as u could see I tried.


#6

If you wanna have 1 big output of all that arrays, then you probably need to loop over each one and push values in 1 new array that you will print out all that values together.

Or if it doesn't matter, you can loop over arrays 1 by 1 and print them out 1 by 1.


#8

why the flag? You got the solution, so? that is good right? Just make a reply here that you solved the problem


#9

Sorry I am guite new to this site. I think I had to write a reason why I deleted my comment. Wont happen again.


#10

It always comes back to for loop.
If you loop like for(var i = 0; i <3; i++){} your i will have values

0 in first loop,
1 in second loop,
2 in third loop,
and 3 when it goes out of the loop.

So you use i as a number placement and go

for 1. array of arrays -> push value[0], value[1], value[2], value[3] in it.
then go to next array in arrays and again push values from 0 to 3....


#11

thankfully not, then we would have a lot of flags. They are your replies, you can delete them whenever you feel like it


#12

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.