Program prints questions for user input, but won't show the answer output

Jake Kobs kobsx4 at gmail.com
Wed May 18 21:04:27 EDT 2016


Here is the code:

#Lab 9-4 Blood Drive

#the main function
def main():
  endProgram = 'no'
  while endProgram == 'no':
    print 
    # declare variables
    pints = [0] * 7
    totalPints = 0
    averagePints = 0
    highPints = 0
    lowPints = 0
    
    
    
    
    
    
   
    
    
    

    
    # function calls
    pints = getPints(pints)
    totalPints = getTotal(pints, totalPints)
    averagePints = getAverage(totalPints, averagePints)
    highPints = getHigh(pints, highPints)
    lowPints = getLow(pints, lowPints)
    displayInfo(averagePints, highPints, lowPints)
   
    endProgram = raw_input('Do you want to end program? (Enter no or yes): ')
    while not (endProgram == 'yes' or endProgram == 'no'):
      print 'Please enter a yes or no'
      endProgram = raw_input('Do you want to end program? (Enter no or yes): ')

#the getPints function
def getPints(pints):
    counter = 0
    while counter < 7: 
        pints[counter] = input("Enter pints collected: ")
        counter = counter + 1
    return pints
#the getTotal function
def getTotal(pints, totalPints):
    
    counter = 0
    while counter < 7:
        totalPints = totalPints + pints[counter]
        counter = counter + 1
    return totalPints
#the getAverage function
def getAverage(totalPints, averagePints):
    averagePints = totalPints / 7
    return averagePints
#the getHigh function
def getHigh(pints, highPints):
    highPints = pints[0]
    counter = 1
    while counter < 7:
        if (pints[counter] > highPints):
            highPints = pints[counter]
            counter = counter + 1
    return highPints
#the getLow function
def getLow(pints, lowPints):
    lowPints = pints[0]
    counter = 1
    while counter < 7:
        if (pints[counter] < lowPints):
            lowPints = pints[counter]
            counter = counter + 1
    return lowPints
#the displayInfo function
def displayInfo(averagePints, highPints, lowPints):
    print "The average pints donated was: ", averagePints
    print "The highest amount of pints donated was: ", highPints
    print "The lowest amount of pints donated was: ", lowPints
    return displayInfo(averagePints, highPints, lowPints)
    
main()

The problem is that the display info isn't shown after the user types in their 7 numerical values. Please help.



More information about the Python-list mailing list