On Wed, Feb 4, 2015 at 1:01 AM, Андрей Пугачев <pugachov.and...@gmail.com> wrote: > Hi > I'm learning python a few weeks and have problems with code that read text > from txt-file > Code doing all right, but in the end I have error > > Traceback (most recent call last): > File "trivia_challenge.py", line 81, in <module> > main() > File "trivia_challenge.py", line 74, in main > category, question, answers, correct, explanation, points = > next_block(trivia_file) > File "trivia_challenge.py", line 37, in next_block > points = int(next_line(the_file)) > ValueError: invalid literal for int() with base 10: ''
Your next_line() function looks a little off. Let's take a look at it: ############################################ def next_line(the_file): """Return next line from the trivia file, formatted.""" line = the_file.readline() line = line.replace("/", "\n") return line ############################################ What do you want to happen here, when there are no more lines in the file to read? _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor