aa = (1, 2, 3, 4, 5, 6)
b = [(x == 5 and 8 or x) for x in aa]

z = map(lambda x: 8 if x == 5 else x, [i for i in b])

print(b)
print(z)

 

相关文章: