+ 10
Why am I unable to import argument variables in Python? [SOLVED]
From Zed. A. Shaw's tutorials, I've learned that we can import argv and assign values to it. I've tried my best to follow accordingly, but it's saying "Not enough values to unpack....." From what I've heard, this is a common problem, and some also told me that Sololearn's code playground can't run it. Can someone please explain? I really want to learn this... https://code.sololearn.com/cofe923eAAXL/?ref=app
6 odpowiedzi
+ 10
hi, argv does only contian 2 elements in this case, so you can not unpack to 4 variables:
from sys import argv
print(len(argv))
for i in argv:
print(i)
#script, first, second, third = argv
#print("The script is called:", script)
argv is not intended to do inside an IDE or PlayGround. you can find more information here:
https://www.pythonforbeginners.com/argv/more-fun-with-sys-argv
+ 5
Thanks Mirielle🐶 [Inactive] it helped :D
+ 3
Ro Nin questions already have "upvote" and "downvote" 🤔
It's in the top left corner of the question
+ 2
K.M Ahnaf Zamil that's my autocorrect maybe, and what you did up there is spamming, which is not allowed here; so please modify your answer before you get a mod note😂
And I did Google it... One guy had the same problem in StackOverflow, and nobody answered him🙃
+ 1
It would be really nice for all questions to have a "like" and "dislike" option, here. Perhaps on the next #SoloLearn upgrade?
- 1
Hey I dont know the "Python"-ical answer so I said my "Logical" answer. The amount of time you spent scrolling the blank space are the drumroll time for my answer. (Hopeless).