Program prints questions for user input, but won't show the answer output
John Gordon
gordon at panix.com
Wed May 18 21:16:49 EDT 2016
In <1cc14787-7061-45c9-a70e-1b16e3f5ef3a at googlegroups.com> Jake Kobs <kobsx4 at gmail.com> writes:
> Here is the code:
> def getHigh(pints, highPints):
> highPints = pints[0]
> counter = 1
> while counter < 7:
> if (pints[counter] > highPints):
> highPints = pints[counter]
> counter = counter + 1
> return highPints
getHigh() goes into an infinite loop if pints[counter] is less than or
equal to highPints.
> def getLow(pints, lowPints):
> lowPints = pints[0]
> counter = 1
> while counter < 7:
> if (pints[counter] < lowPints):
> lowPints = pints[counter]
> counter = counter + 1
> return lowPints
And getLow() has a very similar problem.
I suspect you want to unindent the 'counter = counter + 1' statement
so that it is NOT inside the 'if' statement.
--
John Gordon A is for Amy, who fell down the stairs
gordon at panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
More information about the Python-list
mailing list