. Advertisement .
..3..
. Advertisement .
..4..
I am trying to write a python that returns an invalid answer. I don’t know where the incorrect command is in the “valueerror: need more than 1 value to unpack.” My detail is:
from sys import argv
script, user_name =argv
prompt = '>'
print "Hi %s, I'm the %s script." % (user_name, script)
and I end up with the warning message:
Traceback (most recent call last):
script, user_name =argv
ValueError: need more than 1 value to unpack
Please suggest the best answer to fix it.
The cause: Most likely, you didn’t give a command-line parameter. In that situation,
sys.argv
only has one value, when it would need two to give values for bothuser_name
andscript
.Solution: To fix the “ValueError: More than one value is needed to unpack”, do like this:
You are getting “ValueError”: More than one value is needed to unpack this error because you gave only one value, which in this case was ex14.py.
The problem is that you forgot to include a name when you ran the.py files.
Line 3 in your code is
The script is ex14.py. You forgot to add a name.
So if your name is michael, then what should you type into the terminal?
Make this change, and the code will run perfectly