-2

I want to get all the arguments used in my python script in a variable

    print("\nArguments passed:", end = " ")
    n = len(sys.argv)
    for i in range(1, n):
        command = sys.argv[i]
        print(command)

how I can retrieve them in one row like :

print(command, end= " ")
arg1 arg2 arg3 arg3

Thanks for your help

Flora8832
  • 57
  • 5

2 Answers2

0

I would go with:

import sys

args = ' '.join(sys.argv)

print(args)
Paul P
  • 3,346
  • 2
  • 12
  • 26
-1
print("\nArguments passed:", end = " ")
    n = len(sys.argv)
    for i in range(1, n):
        command = sys.argv[1:]
    


print(command)
Flora8832
  • 57
  • 5