我正在尝试使用下面的代码从带有公共分隔符的字符串列表生成组合列表,而不使用反向重复:
separator = "*";
VarList = ["y","lp","ep","rmp","cmp","cp","fp"]
newVarList = [];
currPosition = 0
for currVar in VarList:
currPosition +=1
nextPosition = 0
for nextVar in VarList:
nextPosition+=1
if currPosition != nextPosition:
currText = currVar + separator + nextVar
if currText not in newVarList:
newVarList.append(currText)
print len(newVarList)
print(' '.join(map(str, newVarList)))
我已经设法产生了组合,并有他们列出没有括号或引号,但反向重复仍然存在。任何建议都将不胜感激
确保当前位置始终小于下一个位置: 也许通过改变
至
这样就可以去掉重复的部分
相关问题 更多 >
编程相关推荐