• Register
1 vote
103 views

Problem:

I am getting an error while I am trying to run a python program. Please have a look at it and give me a solution if possible. I am trying to figure the problem but I fail to do so.

from sys import argv
script, usr_name =argv
prompt = '>'
print "Hello %s, I'm the %s script." % (usr_name, script)

Here is the error, “valueerror need more than 1 value to unpack

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

Thanks.

12 7 7
15,250 points

1 Answer

1 vote

Solution:

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 usr_name and scrip

.Try something like this below:

script, one, two = argv
print "My file is:", script
print "My first entry is:", one
print "My second entry is:", two

I hope you get the point. So, fix the error this way and try to run the program again. Let me know if it works or not. If works, leave a kudos.
You are welcome.

13 9 6
94,240 points

Related questions

1 vote
1 answer 61 views
61 views
Problem: For the following code I got some error message like: ValueError: not enough values to unpack (expected 3, got 2) The code: import openpyxl, smtplib, sys wbs = openpyxl.load_workbook('duesRecords.xlsx') sheet = wb.get_sheet_by_name('Sheet1') lastCol = sheet. ... problem sending email to %s: %s' % (email, sendmailStatus)) smtpObj.quit() Can anyone help me out to solve this problem?
asked Apr 8 LizzyM 6.1k points
0 votes
2 answers 1.3K views
1.3K views
Problem : I got following rather cryptic error message: the truth value of an array with more than one element is ambiguous. use a.any() or a.all()
asked Nov 18, 2019 peterlaw 6.9k points
1 vote
1 answer 24 views
24 views
Problem: I am getting the 'valueerror:too many values to unpack' error. Any idea how I can fix this? Here is my sample program first_names = ['foo', 'bar'] last_names = ['gravy', 'snowman'] fields = { 'first_names': first_names, 'last_name': last_names, } for field, possible_values in fields: # error happens on this line
asked Mar 7 Gavin 15.3k points
1 vote
1 answer 75 views
75 views
Problem: Hello Kodlogs, I am going through a problem for the last few minutes. I tried to solve it in many ways but still couldn’t get rid of this. I’ve learning c++ programming language from last week. So, you can treat me as a novice in it. I have a ... (addr,retstring().c_str()); And the function I tried to call: void Printfunc(int a, char *loc, char *stream) Thanks. Good day!
asked Mar 29 Gavin 15.3k points