Python argv issue -


#python 3.0 sys import argv  script, user_name = argv prompt = "> "  print("hi %s, i'm %s script." % (user_name,script)) print("i ask few questions.") print("do me %s?" % user_name) likes = input(prompt)  print("where live %s?" % user_name) lives = input(prompt)  print("what kind of computer have?") computer = input(prompt)  print(""" alright said %r liking me. live in %r. not sure is. , have %r computer. nice. """ % (likes, lives, computer)     ) 

i getting following error:

script, user_name = argv valueerror: need more 1 value unpack 

please help

try

len(argv) 

to see how many elements argv has. problem there mismatch between number of elements in argv , number of variables you're trying assign to.

here simplified case of problem:

>>> one, 2 = [1] # cannot this! valueerror: need more 1 value unpack >>> one, 2 = [1, 2] # ok! 

to fix this, make sure pass argument script

python your_script.py user_name 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -