Вы должны иметь списки вместо кортежей
a = [[1, 2], [3, 4], [4, 5], [6, 7], [5,90]]
b = [[1, 2], [10, 1], [3, 1], [4, 9], [10,9]]
z = 90
for n,na in enumerate(a):
if na[1] >= b[n][1]:
if na[1] < 89:
a[n][1] += 2
print(a)
Кортежи
Это код, если вам нужно иметь вывод в кортеже
a = [(1, 2), (3, 4), (4, 5), (6, 7), (5,90)]
b = [(1, 2), (10, 1), (3, 10), (4, 9), (10,9)]
a1 = [list(x) for x in a]
b1 = [list(x) for x in b]
z = 90
for n,na in enumerate(a1):
if na[1] >= b1[n][1]:
if na[1] < 89:
a1[n][1] += 2
elif na[1] == 89:
a1[n][1] = 90
a = [tuple(x) for x in a1]
print(a)
[(1, 4), (3, 6), (4, 5), (6, 7), (5, 90)]
Если вы хотите, чтобы numpy это делал
import numpy as np
a = [(1, 2), (3, 4), (4, 5), (6, 7), (5,90)]
b = [(1, 2), (10, 1), (3, 10), (4, 9), (10,9)]
a, b = np.array(a), np.array(b)
z = 90
second_element = np.s_[:, 1]
is_bigger = a[second_element] >= b[second_element]
a[second_element][is_bigger] = np.clip(a[second_element][is_bigger] + 2,
a_min=None, a_max=z)
a = [tuple(x) for x in a]
print(a)
выход
[(1, 4), (3, 6), (4, 5), (6, 7), (5, 90)]