What's happening
input() returns a string (characters you entered, for example, "123"), but you get a TypeError because you are passing a string to something that expects a number (like 123, without quotes).
Decision
The fix converts the string to a number, passing it through the int(...) constructor, for example. int(input()) (just like int("12") will give you 12 ).
I would like to apologize if you are not new to programming, and it was a stupid mistake, but in case you are new to, here is my thought process that helped me debug the problem. I hope you do not find this condescending; I share my thinking process, so others in such situations can correct such errors.
How to diagnose these problems
You debug this as follows, returning one step at a time:
The first test is for you to understand how to make an array correctly. For example, I would try to create a 3x3 array to make sure I understood the API.
>>> array(..., [3,3]) <array object at 0x...>
Ok, it worked! It seems we can make array right if we just enter the numbers array(..., [3,3]) . Now try with input() .
>>> boardsize = input() >>> array(..., [boardsize, boardsize]) TypeError: string indices must be integers
This is odd. I just created a 3x3 array(..., [3,3]) with array(..., [3,3]) , why doesn't array(..., [boardsize, boardsize]) ? Check if the boardsize value is boardsize :
>>> boardsize '3'
How strange the value seems to be 3 , right? Let me check to make sure.
>>> boardsize == 3 False
Wait, '3'! = 3 ??? How does "3" not match 3?
>>> type(boardsize) <class 'str'>
Ahh! ' I see that this is a string. It should be such that input returns a string. This makes sense, for example, I can enter "cat" and make boardsize == 'cat' , and I should not expect python to determine if an arbitrary string is a number.
>>> '3' '3' >>> 3 3 >>> boardsize '3'
The fix will be related to google for python convert string to number : second hit: "use the int(...) built-in function
tl; dr: Make your way back to error by checking yourself at every step. When you start making large programs, you can use automatically called health check functions and “unit tests” to make debugging easier.
(sidenote: If you are interested in how objects are printed, this comes from the special __repr__ method that all classes define. Calling repr(something) will pretty clearly show which object something ; repr automatically called at the output of what you enter into the interactive interpreter.)