-3

I'm writing a program from "Learn Python the Hard Way - Third Edition" by Zed A. Shaw. I am new to programming and I am completely stuck on Exercise 12. Please look at my code and help me with what I am doing wrong, as for all I know it is exactly as it should look in the book

from sys import argv

script, first, second, third = argv

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

The complete error message is as follows (I struggle to understand it due to inexperience)

Traceback (most recent call last):
  File "ex13.py", line 3, in <module>
    script, first, second, third = argv
ValueError: need more than 1 value to unpack
Carcigenicate
  • 43,494
  • 9
  • 68
  • 117
DamonT
  • 15
  • 4
  • 3
    Show how you're running the script. It seems it's expecting three arguments passed in, but you aren't passing any. If you're just double clicking the python file, you'll need to run it in a batch file or from the command line and pass data in. The book likely showed you how to do that before showing you this code. – Carcigenicate May 18 '19 at 20:40
  • Carcigenicate, thank you. I hadn't understood that bit of text in the book, but now I do thans to your comment. I am now running the program correctly, thank you – DamonT May 18 '19 at 20:47

1 Answers1

-1

So probably you were using more args than actually passing the same lengthed args 1

Here is the execution if you pass less than actually using them in the script.2

Please Find Attachments.

shyamzzp
  • 115
  • 7