如何使此代码在没有语法错误的情况下运行? [英] How do I get this code to run without a syntax error?
本文介绍了如何使此代码在没有语法错误的情况下运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
board = []
for row in range(3):
board.append([])
for column in range(3):
# Assign x to each row
board[row].append('x')
def print_board(board):
for row in board:
print " ".join(row)
print_board(board)
我尝试过的事情:
我已经尝试在python中添加括号并消除错误周围的空间.
What I have tried:
I''ve tried adding brackets and removing the space around the error in python.
推荐答案
您的打印语句不正确,应该是:
Your print statement is incorrect, it should be:
print (" ".join(row)) # note outer parentheses
这篇关于如何使此代码在没有语法错误的情况下运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文