嘿,初学者,我有一个家庭作业,我有一个列表,为了更容易理解,我举了一个例子,现在让我们把列表= 1,2,4,6,5,9,if 4-2 > 2-1加到一个新的列表中,数字1,2,4,6-4不大于4-2,所以不要把6加到列表中,下面是我写的代码 lst4 = [1, 2, 4, 7] # Replace the assignment with other lists to test your code
x = [x for x in stockslist if stock in x][0]
print(stockslist.index(x)[1] - stockdeposit)当我运行这段代码时,我会收到以下错误:TypeError: 'int' object is not subscriptable