如何在Python中使用集合和dict?
大家好!
我需要创建一个类似于此解释的程序
选择 | 换行 | 行号
- for each word in the input text:
- set a variable equal to the length of the set
- add word to the set
- if the length of the set is greater than the length of the "old" set:
- add the word to the dict
- for k, v in words.items():
- print(k, v)
我是新手,所以要解决这个问题对我来说非常困难。有谁可以帮我?
先谢谢你