Basically, I have a list with the following words
['ask', 'not', 'what', 'your', 'country', 'can', 'do', 'for', 'you', 'ask', 'what', 'you', 'can', 'do', 'for', 'your', 'country']
(this was the example given to me by my teacher and it is pretty good for testing).
I want to figure out how to remove any duplicates and print out the new list without said duplicates, so the output should be
['ask', 'not', 'what', 'your', 'country', 'can', 'do', 'for', 'you']
After initially trying to use the set(), I managed to remove the duplicates, but it just prints out the sentence in a random order, which is quite bothersome.
Here is my code:
sentence = input('Please enter a sentence. No punctuation may be included: enter code here').lower().split()
print('This is your sentence:', sentence)
no_duplicates = list(set(sentence))
print('This is your sentence without duplicates', no_duplicates)
By the way, incase you didn't notice, I'm still quite a newb to coding so try and keep your answers simple so that I may understand what you're saying.