私はこのコードを入れました:
def game():
down, right = 0, 0
while 1:
for i in range(down):
print "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
for j in range(right):
print "0",
print "S",
for j in range(80 - (right + 1)):
print "0",
for i in range(38 - (down + 1)):
print "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
direction = raw_input("Direction?")
if(direction.upper() == "W"):
down -= 1
elif(direction.upper() == "S"):
down += 1
elif(direction.upper() == "A"):
right -= 1
elif(direction.upper() == "D"):
right += 1
game()
'print "S",' は最後にカンマを付けて、次に print 関数を呼び出したときに次の行で印刷を停止する必要があります。
実際には次のような結果になりました: (「000000」を含むいくつかの行を切り刻みました)
S 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000
最初のゼロの間にスペースがあるのはなぜですか? 私の印刷機能にはスペースがありません。