When I try to run the programs in Learn Python the Hard Way, I'm having problems with the following line of code (understand names as generic parameters):
nome, nome, nome = argv
In different exercises I tried to do the following: (nome, nome, nome = argv, "referencia", "referencia")
and so it worked. But I do not understand why what is in the book and what should work from the code copy is returning this error.
To complement this post, I will pass here the code of the ex in question that I am having this error, but keep in mind that all others that have this line of code informed above, also return ValueError
. >
from sys import argv
script, user_name = argv
prompt = '>'
print(f"Hi {user_name}, i'm the {script} script.")
print(" i'd like to ask you a few questions.")
print(f"Do you like me {user_name}?")
likes = input(prompt)
print(f"Where do you live {user_name}?")
lives = input(prompt)
print("What kind of computer do you have?")
computer = input(prompt)
print(f"""
Alright, so you said {likes} about liking me.
You live in {lives}. Not sure where that is.
And you have a {computer} computer. Nice.
""")
I'm getting the following error:
Traceback (most recent call last): File "C: \ Users \ MAPB \ Desktop \ Learn Python the Hard Way \ ex 14.py", line 3, in script, user_name = argv ValueError: not enough values to unpack (expected 2, got 1)
Additional information:
I'm saving the exercises from the book in a folder on the Desktop, that is, they are not in the directory where python is installed. I use windows 8.1.