我有一些代码,我打算打印出将由用户输入的字符串中的所有唯一单词:
str1 = input("Please enter a sentence: ")
print("The words in that sentence are: ", str1.split())
unique = set(str1)
print("Here are the unique words in that sentence: ",unique)
Run Code Online (Sandbox Code Playgroud)
我可以让它打印出唯一的字母,但不能打印出唯一的单词。