2013-07-26 52 views
0

我不確定爲什麼我的解決方案無法正常工作。我通過'間諜',然後添加一個到列表的第三個元素。Udacity Python替換列表中的數字

在此先感謝!

# 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] 

回答

0

在該功能中,您應該執行a

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

當...關閉。謝謝一堆。 – AwayFromMyDesk