该代码应该将项目添加到几个字典(单价,说明,库存)。但是问题是当我运行代码时,突出显示了变量名p_desc。
我尝试删除整个语句,导致p_stock突出显示。仅当删除整个elif语句时,代码才会运行。
while(c!= "q" or c!= "Q"):
c= input("What would you like to do?")
if(c=="q" or c=="Q"):
break
elif(c=="A" or c=="a"):
p_no = int(input("Enter part number: "))
p_pr = float(input("Enter part price: ")
p_desc = input("Enter part description: ")
p_stock = int(input("Enter part stock: "))
for i in range(0,len(unit_price)):
if(p_no in unit_price):
print(p_no,"That part number already exists :(, changing value to")
p_no+=1
unit_price.update({p_no: p_pr})
description.update({p_no: p_desc})
stock.update({p_no: p_stock})
print()
答案 0 :(得分:0)
您还没有关闭上面一行中的括号
p_pr = float(input("Enter part price: ")
您需要关闭两个括号
p_pr = float(input("Enter part price: "))
答案 1 :(得分:0)
您错过了2个右括号。
更改:
p_pr = float(input("Enter part price: ")
p_desc = input("Enter part description: ")
收件人:
p_pr = float(input("Enter part price: "))
p_desc = input("Enter part description: "))