I think I now understand why I am getting this EOF exception. On Fri, Oct 7, 2016 at 10:16 PM, boB Stepp <robertvst...@gmail.com> wrote: > My current get_input() function: > > ====================================================== > def get_input(): > '''Get string input from the user and convert it to an integer. This > integer is returned to the caller. > > :num_sides: Number of sides for the displayed grid.''' > > while True: > try: > num_sides = int(input("Number of sides = ")) > return num_sides > except ValueError: > print("'Number of sides' must be a positive integer. Please > enter " > "an integer.") > =======================================================
Since the try/except is within a while loop, the input tries to read more input after the ValueError occurs. Of course, I don't have any more input strings stored in the StringIO buffer, so it sees this as an end of file condition. But now I do not see how to test get_input() to check for the ValueError. Any suggestions? boB _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor