LoginSignup
0
0

More than 1 year has passed since last update.

Get the index of the list as the argument

Posted at
  • test.py
import sys

class Test:
    l = [[1,3],[2,4]]

a = [1,3]
print(",".join(map(str,a)))

for k,v in enumerate(Test.l):
    jmv = ",".join(map(str,v))
    if jmv == sys.argv[1]:
        print("hit, argv,k",sys.argv[1],k)

  • execution
# python3 test.py 1,3
1,3
hit, argv,k 1,3 0
# python3 test.py 3,9
1,3
# python3 test.py 2,4
1,3
hit, argv,k 2,4 1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0