logs = ["A", "B", "B", "C", "A"] result = [logs[0]] for i in range(1, len(logs)): if logs[i] != result[-1]: result.append(logs[i]) print(result)
To embed this project on your website, copy the following code and paste it into your website's HTML: