Alex Rivera | Logout

Python Error: "ValueError: need more than 1 value to unpack"

Asked 2010-05-11T20:16:39.353
48

In Python, when I run this code:

from sys import argv

script, user_name =argv
prompt = '>'

print "Hi %s, I'm the %s script." % (user_name, script)

I get this error:

Traceback (most recent call last):  
script, user_name =argv  
ValueError: need more than 1 value to unpack

What does that error mean?

Edit
Report

2 Answers

8

youre getting ''ValueError: need more than 1 value to unpack'', because you only gave one value, the script (which is ex14.py in this case)

the problem is, that you forgot to add a name after you ran the .py file.

line 3 of your code is

script, user_name = argv

the script is ex14.py, you forgot to add a name after

so if your name was michael,so what you enter into the terminal should look something like:

> python ex14.py michael

make this change and the code runs perfectly

answered 2013-02-07T01:24:37.563
1

I assume you found this code on Exercise 14: Prompting And Passing.

Do the following:

script = '*some arguments*' 
user_name = '*some arguments*'

and that works perfectly

answered 2012-08-08T14:11:05.233

Your Answer