我应该写函数randomWorld
。它接受表示世界宽度和高度的两个整数width和height,并返回表示世界的dict。我一直在遵循老师的算法思想,但现在我明白了
SyntaxError cannot assign to function call
这就是我所做的
def randomWorld(width, height):
"""Return a random world"""
world={}
for x in range(width):
for y in range(height):
if random.randint(0,10) < 3:
world.Cell(x,y)=True
return world
我想你只是想:
相关问题 更多 >
编程相关推荐