arguments – Python Error: ValueError: need more than 1 value to unpack

arguments – Python Error: ValueError: need more than 1 value to unpack

Probably you didnt 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.

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

arguments – Python Error: ValueError: need more than 1 value to unpack

You cant run this particular piece of code in the interactive interpreter.
Youll need to save it into a file first so that you can pass the argument to it like this

$ python hello.py user338690

Leave a Reply

Your email address will not be published.