遇到一道題,要求定義一個函式updateR(R[i, t]),將已知array R的[i ,t]位置的元素作為引數,運行函式后得到R[i, t+1]。
如,已知array R:
R = [[1 0 1 0]
[0 1 0 1]
[0 0 5 1]
[1 1 1 0]
[1 1 0 1]
[1 0 1 0]
[0 1 0 1]
[0 0 1 0]
[1 1 0 1]]
運行updateR(R[2, 1])后應該得到R[2,2]的值,即5。但是,當我對updateR定義時:
def updateR(R[i, t]):
會顯示SyntaxError: invalid syntax,可能是因為我在引數中使用了方括號?請問大家,這種情況應該怎么解決呢?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/136072.html
上一篇:Python運行出現屬性錯誤
