如果 N 是数组并且 N[1][i] 在 for 循环中,N[1][i] 会做什么?我无法理解

What does N[1][i] do if N is an array and N[1][i] is inside a for loop? I am having trouble understanding

所以我查看了一些 python 代码并遇到了这段代码:它应该扫描字符串中数字的所有实例,但我并没有真正理解它。这是我的代码:

inp = open("socdist1.in").read().strip().split()

print(inp)

n = int(inp[0])

cow_places = []
for i in range(n):
    if (inp[1][i] == "1"):
        cow_places.append(i);
print(cow_places)

感谢 Poke、Navaneeth Reddy 和 Hamza 回答我的问题 对于感兴趣的人,答案是 N[1][i] 是两件事的一部分:N[1] 部分是数组的第一个位置,而 N[i] 扫描该部分以查找您所在的部分正在寻找。

inp = [14, '10001001000010'] #14 is the length of the string '10001001000010'

print(inp[1]) #outputs '10001001000010'
print(inp[1][0]) #outputs '1'
print(inp[1][2]) #outputs '0'

for i in range(inp[0]): #inp[0] is the length of the string
    print(inp[1][i]) #outputs the i-th character in '10001001000010'

for循环输出如下:

1
0
0
0
1
0
0
1
0
0
0
0
1
0