我有一段代码,它将跳过取决于结果的函数。在一个函数中,我有一个如果找到的语句,这将使结果为真,并通过if下面的代码运行。我也有,如果没有在函数中找到,它会将结果设置为False,以便跳过下面的if语句中的代码。如果结果不止一次使用
while repeatchoice == True:
code = getproductcode()
product = checkfile(code)
result,stocklevel = checkstocklevel(code)
if result:
quantity = quantityFunction(product)
checkquantity = isquantityokay(quantity, stocklevel)
quantity = int(quantity)
update = updatestocklevel(quantity, stocklevel, code)
cost = price(product)
productcost = calculateproductcost(cost, quantity)
rline = receiptline(product, quantity, productcost)
addtoreceipt = append(rline)
addtototal = appendprice(productcost)
repeatchoice = repeat(username)
我已经有“如果结果”在此代码,我需要为另一个结果做同样的(跳过或运行基于某些功能,如果结果返回true或false)
这是可能使用变量'result?'
我已经在使用'if result'我能再次做这个吗?'那么,在我定义数量函数的地方是否可以有另一个“if result”呢?
请更改您的问题,以清楚您所问的内容,您的意思是“为其他结果做什么”(什么是“另一结果”和“做同样的事情”),您的意思是“保持通话” – lejlot
在定义之后,您从未更改过变量'result'。所以是的,你可以重复使用它,确保它没有改变。 –
希望这是更清晰的@lejlot –