我有一个清单:
List1 = ['M1', 'M2', 'M3', 'M4', 'M5', 'M5', 'M5', 'M6', 'M7', 'M7', 'M8', 'M9', 'M10', 'M10', 'M10', 'M11']
我想找到所有的副本,然后在每个副本后面加上小写字母,这样看起来像这样:
List1 = ['M1', 'M2', 'M3', 'M4', 'M5a', 'M5b', 'M5c', 'M6', 'M7a', 'M7b', 'M8', 'M9', 'M10a', 'M10b', 'M10c', 'M11']
我能找到复制品,但我真的不知道该怎么办。你知道吗
任何帮助都将不胜感激!你知道吗
另一个可能的解决方案是一个班轮:
您可以使用列表理解和
string.ascii_lowercase
:输出:
另一种使用
Counter
和enumerate
的简单方法:相关问题 更多 >
编程相关推荐