1
from sys import argv

script, first, second, third, = argv

print "The script is called:", script
print "Your first variable is:", first
print "Your second variable is:", second
print "Your third variable is:", third

This is the code from "Learn Python the Hard Way", but it doesn't run and I don't know why.

The resulting error is as follows:

Traceback (most recent call last):
  File "E:/python/untitled1/new.py", line 6, in <module>
    script, first, second, third, = argv
ValueError: need more than 1 value to unpack
TankorSmash
  • 12,186
  • 6
  • 68
  • 106
vankee
  • 93
  • 1
  • 9

1 Answers1

1

You need to make sure that the arguments you pass to the script when it's run are more than 1. In a terminal, your script would throw the error:

$ python ./script.py

but this would not

$ python ./script.py arg1 arg2 arg3

Since you're using PyCharm, you'd need to do the 'Before launch/show this page' and edit them there.

Community
  • 1
  • 1
TankorSmash
  • 12,186
  • 6
  • 68
  • 106