Python打印没有在控制台没有明显的原因?

Dig*_*can -2 python printing variables integer nonetype

我的程序在网格中绘制框.这是完整的代码:http://pastebin.com/cMEJAAES

这里的想法是我需要一个调试方法.它应该打印乌龟刚绘制的盒子的坐标,它的颜色.由于某种原因,它打印很好,但中间有一个随机的无.这是一些控制台输出的示例:

Reading map data....
Drew tile 1 (1,1)
None as color 3
Drew tile 2 (1,2)
None as color 0
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

#Define our map to draw.
map = [3,           #Set row width.
        3, 0, 0,    #Row data.
        0, 2, 1,
        2, 1, 1]
Run Code Online (Sandbox Code Playgroud)

[...]

def drawmap(m):
#Print the entire map.
    for x in range (0, len(m)):
        if x == 0:
            print("Reading map data....") #Not really, just skipping index 0.
        else:
            draw_tile(map[x])
            lastbox = x
            tileinfo(x)
            move(m, lastbox)

def tileinfo(index):
    print ("Drew tile ", end='')
    print (index, end='')
    print (getcoords(index), end='')
    print (" as color ", end='')
    print (map[index])

def getcoords(index):
    print (" (", end='')
    print ((index // map[0]) + 1, end='')
    print (",", end='')
    if (index % map[0]) == 0:
        print (map[0], end='')
    else:
        print (index % map[0], end='')
    print (")")
Run Code Online (Sandbox Code Playgroud)

为什么会这样?

非常感谢!

mgi*_*son 5

getcoords返回None,所以:

print (getcoords(index), end='')
Run Code Online (Sandbox Code Playgroud)

将a打印None到控制台.