Sep-05-2019, 08:27 PM
@ecdhyne
line 8 should print list with file name and all CLI arguments
The problem with lines 9-11 is the closing place where you put closing parenthesis of print function. As is now each line is just at 2-element tuple (so a valid code)
let's look at line 9
print ('This is the name of the script: '), sys.argv[0]
it execute the print function (everything before the comma)
print ('This is the name of the script: ')
print function returns None
here the line in interactive mode
lines 9-11 should be
line 8 should print list with file name and all CLI arguments
The problem with lines 9-11 is the closing place where you put closing parenthesis of print function. As is now each line is just at 2-element tuple (so a valid code)
let's look at line 9
print ('This is the name of the script: '), sys.argv[0]
it execute the print function (everything before the comma)
print ('This is the name of the script: ')
print function returns None
here the line in interactive mode
>>> import sys >>> print ('This is the name of the script: '), sys.argv[0] This is the name of the script: (None, '') >>> print ('Number of arguments: '), len(sys.argv) Number of arguments: (None, 1) >>> print ('The arguments are: ') , str(sys.argv) The arguments are: (None, "['']")
lines 9-11 should be
print ('This is the name of the script: ', sys.argv[0]) print ('Number of arguments: ', len(sys.argv)) print ('The arguments are: ', str(sys.argv))or better use string formatting, e.g. str.format() or f-strings
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs