0

我不确定为什么我的解决方案不起作用。我通过“间谍”,然后将一个添加到列表的第三个元素。

提前致谢!

# Define a procedure, replace_spy,
# that takes as its input a list of
# three numbers, and modifies the
# value of the third element in the
# input list to be one more than its
# previous value.

spy = [0,0,7]

def replace_spy(a):
    replace_spy[2] +1


# In the test below, the first line calls your 
# procedure which will change spy, and the 
# second checks you have changed it.
# Uncomment the top two lines below.

replace_spy(spy)
print spy
#>>> [0,0,8]
4

1 回答 1

0

在函数中,您应该执行 on a

def replace_spy(a):
    a[2] += 1
于 2013-07-26T03:42:58.783 回答