O'Reilly Forums: Chapter 4 Problem - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chapter 4 Problem

#1 User is offline   roygam 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 26-February 11

  Posted 26 February 2011 - 12:09 PM

When I run the highest score code from page 124 - 125 I get the followinf error:

Traceback (most recent call last):
File "C:\Documents and Settings\Administrator\Start Menu\My Documents\highest_score", line 4, in <module>
(name, score) = line.split()
ValueError: need more than 0 values to unpack

Any ideas why? I've rechecked what I typed in with the book and can't find any errors.

Thanks for the help!!
0

#2 User is offline   paulbarry 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 306
  • Joined: 20-August 09

Posted 28 February 2011 - 08:37 AM

This error can appear when you are using the wrong version of the data file. Ensure you are using the right data file. It can also occur when the data file is missing, and this message is Python's way of telling you that you are trying to split data that is "non-existent" - try checking these first.

--Paul.
0

#3 User is offline   roygam 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 26-February 11

  Posted 28 February 2011 - 08:06 PM

QUOTE (paulbarry @ Feb 28 2011, 08:37 AM) <{POST_SNAPBACK}>
This error can appear when you are using the wrong version of the data file. Ensure you are using the right data file. It can also occur when the data file is missing, and this message is Python's way of telling you that you are trying to split data that is "non-existent" - try checking these first.

--Paul.


Thanks for the help Paul! I thought that the error might involve a problem with the text file. The weird thing is that the program as written on page 119 runs correctly (giving the error shown on that page). When I add the "(name,score)=line.split()" line I get problems. I know that the text file is in the same directory as the program so that's not the problem.

One other issue I've been having is that when I save a program, the dialog box defaults to saving it as a .py file type. But after saving, when I try to reopen the file using the dialog I don't get the file as a .py extension. I have to search for "all files ("*")" to find my program. Do I have a bad install perhaps? Thanks again for the help!

Roy

Update: I think I solved the problem. I changed the program file name suffix to ".py" and reloaded and ran the program correctly. I guess if the file doesn't have the .py suffix it isn't truly opened as a pyhton program. Feeling dopey, but learning!! Thnaks again.

Roy

This post has been edited by roygam: 28 February 2011 - 08:21 PM

0

#4 User is offline   hmarro 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 04-July 12

Posted 18 July 2012 - 10:42 PM

I solved the problem by using a different text editor. I'm a user of Ubuntu, and the very first time I created the text file with Gedit and I got the same error message.

Use a different text editor for creating the "results.txt" file and will run OK.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users