Python Error: “ValueError: need more than 1 value to unpack”

841    Asked by CameronOliver in Python , Asked on Apr 18, 2021

 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 value error need more than 1 value to unpack:

Traceback (most recent call last): 

script, user_name =argv 

ValueError: need more than 1 value to unpack

What does that error mean?

Answered by Cameron Oliver

Reason of getting THIS value error is probably you didn't provide an argument on the command line . In that case, sys.argv only contains one value, but it would have to have two in order to provide values for both user_name and script.



Your Answer

Interviews

Parent Categories