<p>我创建了一个python函数:</p>
<pre><code>def is_cayley_table(table):
try:
if type(table) is not list:
return False
else:
n = len(table)
poss_values = range(0,n)
for i in range(0,n):
if len(table[i]) != n:
return False
for j in range(0,n):
if type(table[i][j]) is int and table[i][j] in poss_values:
return True
else:
return False
except TypeError:
return False
</code></pre>
<p>然后用无效参数调用函数:</p>
<pre><code>is_cayley_table([1, 1, 0], [0, 1, 2], [1, 2, 2])
</code></pre>
<p>我希望函数返回“False”,但现在我得到了:</p>
<pre><code> File "C:/Users/Jack/OneDrive/Documents/comp_project.py", line 27, in <module>
is_cayley_table([1, 1, 0], [0, 1, 2], [1, 2, 2])
TypeError: is_cayley_table() takes 1 positional argument but 3 were given
</code></pre>
<p>如果有人能帮忙,我将非常感激。你知道吗</p>
<p>杰克</p>