我遇到了我的while循環問題。出於某種原因,當不等於Q或q時,不會繼續詢問變量「lotNumber」。儘管變量不等於Q
def main():
lotNumber=""
output=""
todayMonth=getValidMonth("the month for Today's Date: ")
todayDay=getValidDay("the day for Today's Date: ",todayMonth)
todayYear=getValidYear("the year for Today's Date: ")
todayDate=calculateJulianDate(todayMonth, todayDay)
lotNumber=input("Please enter the next lot number or Q to exit: ")
if lotNumber=="Q":
print("================ Egg Grading Report ================")
print("\t"+"\t"+"\t"+str(todayMonth)+"/"+str(todayDay)+"/"+str(todayYear)+"\t"+"\t"+"\t")
print(output)
while lotNumber!="Q" or lotNumber!="q":
lotMonth=getValidLotMonth("the month for the date lot " +lotNumber+ " was laid: ")
lotDay=getValidLotDay("the the day for the date lot " +str(lotNumber) +" was laid: ",lotMonth)
lotYear=getValidLotYear("the the year for the date lot " +str(lotNumber)+ " was laid: ")
lotDate=calculateJulianLotDate(lotMonth, lotDay)
daysOld=todayDate-lotDate
age=daysOld
grade=calculateGradeOfEgg(daysOld)
age=daysOld
output= output=output +str(lotNumber) +"\t" +lotDate +"\t" +age +"\t" +grade+"\n"
lotNumber=gettingLotNumber(lotNumber, lotMonth, lotDay, lotYear, output)
print("================ Egg Grading Report ================")
print("\t"+"\t"+"\t"+str(todayMonth)+"/"+str(todayDay)+"/"+str(todayYear)+"\t"+"\t"+"\t")
print(output)
main()
當然,這裏有不同的功能。我無法得到這個織物,而循環爲我工作!幫助幫助幫助!
謝謝!
您可以分享getsLotNumber()代碼,因爲它在循環結束之前重新分配lotNumber嗎? – kartikg3