这次我试着输入一个句子,比如:helloworld!,通过.split(“”)将其拆分并打印所有可能的组合,但代码会排除错误。你知道吗
x = str(input("Text?"))
x = x.split(" ")
print(x)
ls = []
for i in x:
ls.append(i)
print(ls)
permutated = permutations(ls,len(ls))
for i in permutated:
print(permutated)
ls没用,但我试过用它
Tags:
我正在打印置换,而不是我:(
感谢你在评论中的洞察力。你知道吗
调用置换运算符时,必须使用迭代器来实例化这些值。你知道吗
如果您想更进一步,评估所有组合,而不限于输入中的字数:
相关问题 更多 >
编程相关推荐