我正试图用python重新创建enigma代码,目前我正在获取交换机设置,为此我要确保输入中没有重复的字母(格式为“AB CD EF GH”等)。目前我正在使用默认dict检查输入字符串中每个字母的数量。如果有任何重复,我要能够打印错误,如果没有,则将值存储在列表中(像[AB,CD,EF,GH])我找了很多都没找到,希望你能帮忙。代码如下
global SwitchboardSettings
global d
NSwitchboardSettings = input("Enter the switchboard settings leaving a space between each, there should be 13 pairs: ")
d = collections.defaultdict(int)
for c in NSwitchboardSettings: #Collections module, FIX
d[c] += 1
你的问题有点宽泛,不太精确,所以我希望我在这个代码示例中是对的
相关问题 更多 >
编程相关推荐