Click here to Skip to main content
15,312,009 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am getting a value error :

Traceback (most recent call last):
File "C:\Users\Ubaid Parveez\Documents\Python\Arguments.py", line 18, in <module>
script, user_name = argv
ValueError: not enough values to unpack (expected 2, got 1)

What I have tried:

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(f"What kind of computer you have?")
computer = input(prompt)

print (f"Alright, so you said {likes} about liking me. \n You live in {lives} . Not sure where that is \n And you have a {computer} ")
Posted
Updated 9-Dec-18 23:25pm

1 solution

It is all in the error message !
script, user_name = argv
ValueError: not enough values to unpack (expected 2, got 1)

The code want 2 values, but argv got only one.
   
Comments
Member 14068174 10-Dec-18 6:09am
   
So how to solve it now
Patrice T 10-Dec-18 6:50am
   
either provide a second arg, either check number of args
Member 14068174 10-Dec-18 9:40am
   
how to provide a second arg
Member 14068174 10-Dec-18 9:41am
   
how to provide a second arg
Richard MacCutchan 10-Dec-18 11:00am
   
python scriptname.py arg1 arg2 arg3 ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900