How to eliminate duplicate list entries in Python while preserving case-sensitivity? -


I'm looking for a way to delete duplicate entries from a Python list, but with a twist; The upper list should be sensitive in the final list with priority.

For example, do not just cup and cup between cup and cup Need to keep>. Unlike other common solutions, which suggest to first use less () , I like to keep the case of the string here and in particular I shorten one with one uppercase letter I like to do

Then, I'm trying to turn on this list: [Hello, Hello, World, World, Poland, Poland]

In: [Hello, World, Poland]

How should I do this?

Thanks in advance.

This does not preserve the order of the word , but it is "unique "Creates a list of words preference for the capitalist. [34]: [35]: word [= 'hello', 'hello', 'world', 'world', 'Poland', 'Poland',] in [ [36] in the set (word): Item in Item for Item if item.istitle () or item.title (not in words) outside [36]: ['World', 'Poland', 'Hello' ]

If you want to keep the order secure when you appear in the word, , then you can use:

  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -