"Cast" to int in Python 3.4

python, python-3.x

Solution

`int((y * Board.BoardWidth) + x)` use `int` to get nearest integer towards zero.

def shapeAt(self, x, y):
    return self.board[int((y * Board.BoardWidth) + x)] # will give you floor value.

and to get floor value use `math.floor`(by help of m.wasowski)

math.floor((y * Board.BoardWidth) + x)

Problem

I am writing some simple game in Python 3.4. I am totally new in Python. Code below: ``` def shapeAt(self, x, y): return self.board[(y * Board.BoardWidth) + x] ``` Throws an error: ``` TypeError: list indices must be integers, not float ``` For now I have found that this may happen when Python "thinks" that list argument is not an integer. Do you have any idea how to fix that?

Original source