Search code examples
pythonargvsys

How to pass command line to save into list


How to pass command line to save into list

Disclaimer Please dont say print (ARGV1[0])

import sys
ARGV1 = []
for ARGV in sys.argv[2:]:
    ARGV1.append(sys.argv[2:])
print (ARGV1)

My Out

[['2', '3', '4'], ['2', '3', '4'], ['2', '3', '4']]

My Expected out

['2', '3', '4']

Disclaimer Please dont say print (ARGV1[0])


Solution

  • Just do

    ARGV1 = sys.argv[2:]
    

    Since you have 3 values in input its adding same list 3 times.