如何减去列表中项目的值和变量 python

How do I subtract the value of a item in a list and a variable python

from builtins import int
apple = 'apple'
stockslist = [['apple', 174] , ['amazon', 2558] , ['google', 876] ,    ['facebook', 145] , ['square', 61]]
usersetup = input('What is your username?')
balance = (int(input("How much would you like to deposit")))
userbalance = ([usersetup, balance])
stock =  input('what stock would you like to buy')
operation =  input('don trades or normal trading')
if operation == 'don trades':
  stockdeposit = (int(input("Pick a number between 10 and 200?")))
x = [x for x in stockslist if stock in x][0]

print(4-2)
print(stockslist.index(x)[1] - stockdeposit)

当我 运行 此代码时,我收到错误:

print(stockslist.index(x)[1] - stockdeposit)
TypeError: 'int' object is not subscriptable.

我该怎么做才能减去变量。我读到将 int 放在前面将允许加减等,但事实并非如此。请帮助我!

这里的问题是stockslist.index(x)[1]它return x 列表的索引值(数组下标值)。

请更新这个

print(stockslist[stockslist.index(x)][1] - stockdeposit)