string1 = "calvin klein design dress calvin klein"
words = string1.split()
print (" ".join(sorted(set(words), key=words.index)))
This sorts the set of all the (unique) words in your string by the word’s index in the original list of words.
More Related Contents:
- How do I check if there are duplicates in a flat list?
- How to remove duplicates only if consecutive in a string? [duplicate]
- Python String concatenation with in double quotes [closed]
- User input integer list [duplicate]
- How to extract numbers from a string in Python?
- String comparison in Python: is vs. == [duplicate]
- How can I fill out a Python string with spaces?
- Simpler way to create dictionary of separate variables?
- Remove duplicates by columns A, keeping the row with the highest value in column B
- What does preceding a string literal with “r” mean? [duplicate]
- Convert floating point number to a certain precision, and then copy to string
- Is there a generator version of `string.split()` in Python?
- Extract a string between double quotes
- Keeping only certain characters in a string using Python?
- What does a leading `\x` mean in a Python string `\xaa`
- How do I serialize a Python dictionary into a string, and then back to a dictionary?
- Python reverse-stride slicing
- How to sort the letters in a string alphabetically in Python
- Print all items in a list with a delimiter
- Python: ‘str’ object is not callable
- Element-wise string concatenation in numpy
- How can I copy a Python string?
- FutureWarning: The default value of regex will change from True to False in a future version
- Reverse a string without using reversed() or [::-1]?
- Are strings pooled in Python?
- Most Efficient Way to Find Whether a Large List Contains a Specific String (Python)
- get python dictionary from string containing key value pairs
- Mutable and Immutable Strings in python
- Remove consecutive duplicates in a NumPy array
- Why do I get “TypeError: not all arguments converted during string formatting” trying to substitute a placeholder like {0} using %?