python中for循环的使用
numberList=[1,2,3,4]
complexList=[]
def permutationNum():
for i in numberList:
for j in numberList:
for k in numberList:
if i!=j and k != j and i!=k:
complexList.append(str(i)+str(j)+str(k))
print("共有{}种组合,分别为{}".format(len(complexList),complexList))
permutationNum()
输出结果:
共有24种组合,分别为['123', '124', '132', '134', '142', '143', '213', '214', '231', '234', '241', '243', '312', '314', '321', '324', '341', '342', '412', '413', '421', '423', '431', '432']