"Vincent Balmori" <[email protected]> wrote
It's working fine now with the scoring, but now at the end of the
program
for some reason I get this error message:
"/Users/vincentbalmori/Desktop/Python/py3e_source/chapter07/trivia_challenge2.py",
line 27, in next_block
point = int(next_line(the_file))
ValueError: invalid literal for int() with base 10: ''
Thats because after the last question you try to read another
block and don't check anywhere whether you actually read
anything. Your next_block code just assumes there will
always be valid data there, but at the end of the file there
won't be. You get away with category being blank
because replace() doesn't complain. But int() does.
Your whole approach is very fragile in this respect, it only
takes one small mistake in the data to wreck your program,.
Somethjing like a config file format would be much more
robust (and readable) the config reader module would make
sure you got what you expected back.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor