I am new to python programming and I tried this code:
from sys import argv
script, first, second, third = argv
print "this script is called:" ,script
print "the first variable is called : " ,first
print "the second variable is called : ", second
print "the third variable is called : " ,third
I am getting the error :
Traceback (most recent call last):
File "/Users/richavarma/Documents/first.py", line 4, in <module>
script, first, second, third = argv
ValueError: need more than 1 value to unpack
My output should be as follows:
this script is called: abc.py
the first variable is called: first
the second variable is called : second
the third variable is called : third
python untitled.py 1 2 3 this script is called: untitled.py the first variable is called : 1 the second variable is called : 2 the third variable is called : 3sys.argvexpects command line options. You can't do that from IDLE. Try running it from shell with command line args (like in rth's example)