Ok, uhh... I need help. My loop to keep the program running or to quit isn't working right. Can somebody help me figure it out? I tried a couple of methods, and they didn't work. Do anybody have any idea? By the way, this is for a blood drive program I'm writing... Here's the code:
#The main() function:
def main():
endProgram = "no"
print
while endProgram == "no":
print
# Declare Variables Here:
pints = [0] * 7
pintsTotal = 0
pintsAvg = 0
pintsHigh = 0
pintsLow = 0
# Function Calls Here:
pints = getPints(pints)
pintsTotal = getTotal(pints, pintsTotal)
pintsAvg = getAvg(pintsTotal, pintsAvg)
pintsHigh = getHigh(pints, pintsHigh)
pintsLow = getLow(pints, pintsLow)
info = dispInfo(pintsTotal, pintsAvg, pintsHigh, pintsLow)
endProgram = raw_input ("Do you want to quit the program? Yes or No?: ")
while (endProgram != "yes" or endProgram != "no"):
print "Please enter a yes or no!"
return endProgram == raw_input ("Do you want to quit the program? Yes or No?: ")
#The getPints(pints) function:
def getPints(pints):
counter = 0
while counter < 7:
pints[counter] = input ("Enter pints collected: ")
counter = counter + 1
return pints
#The getTotal(pints, pintsTotal) function:
def getTotal(pints, pintsTotal):
counter = 0
while counter < 7:
pintsTotal = pintsTotal + pints[counter]
counter = counter + 1
return pintsTotal
#The getAvg(pintsTotal, pintsAvg) function:
def getAvg(pintsTotal, pintsAvg):
pintsAvg = pintsTotal / 7
return pintsAvg
#The getHigh(pints, pintsHigh) function:
def getHigh(pints, pintsHigh):
pintsHigh = pints[0]
counter = 1
while counter < 7:
if pints[counter] > pintsHigh:
pintsHigh = pints[counter]
counter = counter + 1
return pintsHigh
#The getLow(pints, pintsLow) function:
def getLow(pints, pintsLow):
pintsLow = pints[0]
counter = 1
while counter < 7:
if pints[counter] < pintsLow:
pintsLow = pints[counter]
counter = counter + 1
return pintsLow
#Function to display the information:
def dispInfo(pintsTotal, pintsAvg, pintsHigh, pintsLow):
print "The total number of pints donated was: ", pintsTotal
print "The highest number of pints donated was: ", pintsHigh
print "The lowest number of pints donated was: ", pintsLow
print "The average # of pints donated was: ", pintsAvg
return
main()