0
Can someone please fix this code?
5 ответов
+ 1
As far as I know, there is nothing wrong in the code.
sys.argv is the list of all the arguments that were passed in the code while calling it. Mind that, it'll take no input, rather you have to pass arguments to it. For example, to run your program you have to go to a terminal and write
$ py.exe ex-13.py 1stinput 2ndinput 3rdinput
Here, sys.argv = [ex-13, "1stinput", "2ndinput", "3rdinput"] # your program's name will be the first or 0th element in the sys.argv .
Hope you understand.
0
Where can i get a terminal?
0
you can use termux for a terminal if you only have mobile. if you have a computer, than just use its terminal
0
Soumaya Islam Rimi
If you use a pc, you already have a terminal.
# Windows: use PowerShell or any other terminal or probably cmd, I've never tested that
# Linux : use Bash shell or just search your apps writing 'terminal'
# Pycharm and most other IDEs: probably beside the output and debug's tab, you'll find Terminal
# Android: download a terminal from play store or use any 3rd party python IDE like Pydroid
[ I've never used any product of Apple, so I don't know about them]
Thanks!
- 1
you are trying to unpack 4 variables into one which could not happen, the error traceback already showed you the error message. Hence, this is how your code should be
import sys
print("The script is called:", sys.argv)
print("Your first variable is:", sys.argv)
print("Your second variable is:", sys.argv)
print("Your third variable is:", sys.argv)
https://www.geeksforgeeks.org/how-to-use-sys-argv-in-JUMP_LINK__&&__python__&&__JUMP_LINK/