Home>

It is required to add 0 or 1 to each nested list when the third element matches. The result is:

[[1, 2, [...], None, 0], [4, 23, [...], 4, 0], [2, 3, [...], 50]].

It should look like this:

[[1,2,3, None, 1], [4,23,3,4,1], [2,3,4,5,0]]
s= [[1,2,3, None], [4,23,3,4], [2,3,4,5]]
i= 0
for (s [i] [2]) in s:
    if (s [i] [2]== 3):
        s [i] [2] .append (1)
    else:
        s [i] [2] .append (0)
    i += 1
print (s)

when the third element coincides with what?

Эникейщик2021-10-13 06:56:19

Correct the cycle of odds, it does anything for you. Even so -for x in s:

MBo2021-10-13 06:57:32

I recommend that you carefully reread the chapter on lists and working with them. There is nonsense written here now in about every line

Эникейщик2021-10-13 06:58:19