我不知道我在哪裏出錯,我嘗試了很多其他的方式來放置它,但我仍然得到一個錯誤。不支持的歌劇類型爲+:'int'和'list'
"if sum([r]) == sum(r[c] for r in Square_1): TypeError: unsupported operand type(s) for +: 'int' and 'list'"
def main():
Square_1 =[[[] for r in range(3)] for c in range(3)]
for r in range(3):
for c in range(3):
User_Input=int(input("Please Enter number :"))
Square_1[r][c]= User_Input
if sum([r]) == sum(Square_1[c][c] for c in range(1)):
if sum([r]) == sum(r[c] for r in Square_1):
LoShuMagic = str('is a Lo Shu Magic Square!')
else:
LoShuMagic = str('is not a Lo Shu Magic Square :(')
print(Square_1)
main()
謝謝你的迴應。 –