Empty-I don’t know how to delete a post
Try arranging the input in one list:
tabledata = 
Then, start to get the input in the list:
for i in range(9): a = input("") tabledata += a
After that, start to output the data in your own.
Can you show me an example of what I would do after
for i in range(9):
a = input("")
tabledata += a
You could make a two dimensional list? Very similar to battleships:
change it to what? The code you posted is of battle ships
I’m supposed to input the x, o, b first then display the board however in the code it displays the board every time player 1 and player 2 inputs a number. How would I change it in the battle ship code
Recall that we concatenate lists, not values.
tabledata += [a]
tablelist += a
are both equivalent.
I tested this on the shell, and worked fine.
for i in range(3): print(str(tabledata[i]) + str(tabledata[i + 1]) + str(tabledata[i + 2] i += 1
For the code
i += 1
Wouldn’t i be an invalid syntax
>>> a =  >>> a += 1 Traceback (most recent call last): File "<pyshell#63>", line 1, in <module> a += 1 TypeError: 'int' object is not iterable >>> a.append(1) >>> a  >>> a +=  >>> a [1, 2] >>>
Ok, I’ll admit I didn’t run this directly in the shell, but I did run this in some code and there wasn’t an error with anything regarding that.
Also, I only tested this with strings, and I haven’t seen an error saying it wasn’t iterable.
Sorry, I didn’t know that
i would automatically iterate through itself. Just remove that line.
It is this form that I refer to in your earlier example, the one which raised the concern, in the first place.
>>> a =  >>> a += "A" >>> a ['A'] >>>
I get it now. We have seen two sides of the die. And lo, here is yet another…
>>> a = 'A' >>> a += ['abc'] Traceback (most recent call last): File "<pyshell#86>", line 1, in <module> a += ['abc'] TypeError: Can't convert 'list' object to str implicitly >>>
It would appear that we need to know and understand limitations so we don’t make any false assumptions in our code design. It would also mean that when there are certain ambiguities about code behavior, we ought to favor instead the more explicit approach at hand. The reader is less likely to make assumptions of their own.
When I remove that line of code, it now shows unexpected EOF while parsing
Do you know what EOF error means? Have you tried googling what it is, and what might cause it?
It means when there’s no data given when calling input
What does the abbreviation EOF even stand for?
that is not the only case which can throw an EOF error. I recommend to read a bit more about EOF errors
Thank you, @mtf. I understand now about iterating and how it works now.
For strings being added to a list, we use this:
a += "b"
And for integers being added to a list, we use this:
a += 
I guess we’re both on the same page now.
Moreover, it technically means that you’re doing some sort of syntax that is wrong to the actual syntax of Python. You’re kind of discontinuing it.