以下if语句是否满足此条件:
If the set increases in size (indicating this word has not been processed before), add the word to the dict as a key with the value being the new length of the set
还是我找错树了?你知道吗
s = set()
d = dict()
text = input("Your text here: ")
for word in text.strip().split():
if word not in s:
s.add(word)
d[word] = len(s)
print(d)
也许更简单的方法
不,我认为那不太对。听起来你应该:
您的代码应该如下所示:
相关问题 更多 >
编程相关推荐