I want to pass multiple arguments using cmd to the python script. below is the code I have used.
import argparse
ap = argparse.ArgumentParser()
ap.add_argument('-n', '--names-list', nargs='+', default=[])
#item1 item2 item3 item4
args = vars(ap.parse_args())
a = args.names-list[0]
b= args.names-list[1]
c=args.names-list[2]
d=args.names-list[3]
print(a)
print(b)
print(c)
print(d)
when I execute the code I got an error message like below.
File "D:\script.py", line 7, in <module>
a = args.names-list[0]
AttributeError: 'dict' object has no attribute 'names'
as I'm very new to this, can somebody help me to solve the problem?