Reputation: 1
I am new to python, I am learning it through reading a book(Learn Python 3 the hard way). There is an exercise(exercise14)in the book can’t be run using iOS Pythonista 3.
The script is below:
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.
""")
But then I got an error:
File "/private/var/mobile/Containers/Shared/AppGroup/726BC931-58AE-44A6-9BE5-067EF23667A4/Pythonista3/Documents/Untitled.py", line 2, in <module>
script, user_name = argv
ValueError: not enough values to unpack (expected 2, got 1)
Please help me to solve this problem , I am very new.
Thank you guys!
Upvotes: 0
Views: 591
Reputation: 161
If you long-press the run ("play") button on Pythonista, you can add the command-line argument that your script is expecting (user name, the script name it gets by default).
Upvotes: 1