Please help python replace text

Hello everyone!
To day, I would like to create new python. I am just new python user.
I would like to replace the next item by “OK” if the row same the row+1. Like this picture.
If you have the way please help me do it. Thank you so much!

@toantrungthach Here you go:

OUT = [IN[0][0]]
OUT.extend("OK" if IN[0][x] == IN[0][x-1] else IN[0][x] for x in range(1,len(IN[0])))

Thank you soooo much AmolShah!!! I can do it! Thank you so much!!!

1 Like