【发布时间】:2020-02-22 19:12:14
【问题描述】:
代码:
from itertools import permutations
L = list(input().split())
List=[]
for char in L[0]:
List.append(char)
length = int(L[1])
###
List.sort()
###
for ele in permutations(List,length):
for i in ele:
print(i,end="")
print()
在编写这段代码时,程序运行得非常好。但 关于将注释行之间的行替换为:
List = List.sort()
此错误正在上升:“NoneType”对象不可迭代 我无法理解这个异常
【问题讨论】:
-
List.sort()不会创建新列表。它修改了原始列表。
标签: python-3.x list