Python 3.x Python名称错误问题

Python 3.x Python名称错误问题,python-3.x,list,insert,nameerror,Python 3.x,List,Insert,Nameerror,我的代码有一个问题,即我有一个namererror,并且我的名字没有定义。虽然我知道我的名字是被定义的 # Create UAS database list that was displayed in the file uas_Stock = [["CS116",1],["CS117",1],["CS118",1],["CS119",1],["CS120",1]] # Ask user to select which UAV they want to check out. uas_out =

我的代码有一个问题,即我有一个
namererror
,并且我的名字没有定义。虽然我知道我的名字是被定义的

# Create UAS database list that was displayed in the file
uas_Stock = [["CS116",1],["CS117",1],["CS118",1],["CS119",1],["CS120",1]]

# Ask user to select which UAV they want to check out.
uas_out = str(input("Which UAV would you like to checkout? "))

# Append stock list to show UAS is checked out
if uas_out == CS116:
    list.insert(0,1, "0")
elif uas_out == CS117:
    list.insert(1,1, "0")
elif uas_out == CS118:
    list.insert(2,1, "0")
elif uas_out == CS119:
    list.insert(3,1, "0")
else:
    list.insert(4,1, "0")
我希望结果会取下uas_out值,然后运行if/else语句并执行其中的任何一个。然后,它将附加列表,以给出特定列表的值0而不是1

当我输入uas_out的值时,我得到的错误是:

NameError: name '(whatever uas_out is/CS116/117/118/119/120)' is not defined.

CS116等是字符串,不是变量,它们需要用引号括起来:

if uas_out == 'CS116':
    list.insert(0,1, "0")
elif uas_out == 'CS117':
    list.insert(1,1, "0")
elif uas_out == 'CS118':
    list.insert(2,1, "0")
elif uas_out == 'CS119':
    list.insert(3,1, "0")
else:
    list.insert(4,1, "0")

非常感谢你。我看这个太久了。我想这就是为什么我没有看到它有多简单。