+ 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

28th Oct 2019, 4:00 PM
Humayra🇧🇩
Humayra🇧🇩 - avatar
6 Antworten
+ 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
28th Oct 2019, 4:11 PM
Lothar
Lothar - avatar
+ 5
Thanks Mirielle🐶 [Inactive] it helped :D
28th Oct 2019, 4:15 PM
Humayra🇧🇩
Humayra🇧🇩 - avatar
+ 3
Ro Nin questions already have "upvote" and "downvote" 🤔 It's in the top left corner of the question
29th Oct 2019, 8:43 AM
Humayra🇧🇩
Humayra🇧🇩 - avatar
+ 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🙃
29th Oct 2019, 9:17 AM
Humayra🇧🇩
Humayra🇧🇩 - avatar
+ 1
It would be really nice for all questions to have a "like" and "dislike" option, here. Perhaps on the next #SoloLearn upgrade?
28th Oct 2019, 8:52 PM
Ro Nin
Ro Nin - avatar
- 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).
29th Oct 2019, 10:05 AM
Ahnaf
Ahnaf - avatar