从键盘输入一句话,单词之间用空格隔开,程序将移除重复出现的单词,并按字母表顺序输出,如何编写?

python编写程序:从键盘输入一句话,单词之间用空格隔开,程序将移
除重复出现的单词,并按字母表顺序输出。如输入:
hello world and practice makes perfect and hello world
again
经过程序处理后的输出是:
again and hello makes perfect practice world

s=input()
s=s.split(" ")
s=list(s)
s=set(s)
s=sorted(s)
for i in s:
    print(i,end=" ")
#hello world and practice makes perfect and hello world again

img

str = input('Please Enter Sentence:')  # 英文输入,空格隔开
word_list = str.split(' ')  # 按照空格分割输入
for word in word_list:  # 去除重复元素
    if word_list.count(word) > 1:
        word_list.remove(word)
word_list.sort()  # 按照首字母进行排序
new=" ".join(word_list)  # 重新组成一句话
print(new)  # 打印输出
sorted(list(set(input().split(' '))))