Skip to content
Advertisement

Replace a series of repeated occurrences in a list?

I would like to replace the consecutive occurrences with the first appearance.

For example if I currently have a list

JavaScript

the desired output will be

JavaScript

I know that I can definitely do this by using a for loop to iterate through the list but is there a more pythonic way of doing it?

Advertisement

Answer

Without import anything:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement