I want to return a list of items from a sequence without any elements with the same value next to each other and preserving the original item order.
I've written a solution that works but my attempt to make this solution more pythonic does not work. It seems the if
statement isn't working; it just returns the whole original sequence in a list.
The solution should be a function and I don't want to use imports.
Def order(iterable):
iter_list = list(iterable)
item_list = []
item_list.append(iter_list[item] for item in range(0, len(iter_list)) if iter_list[item] != iter_list[item -1])
return iter_list
I just need to know why (if iter_list[item] != iter_list[item -1) is not working