有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
作者:互联网
def Permutation():
list = []
for i in range(1,5):
for j in range(1,5):
for s in range(1,5):
#if i!=j&i!=s&j!=s:
if i != j != s!=i:
t=i*100+j*10+s
if t in list:
pass
else:
list.append(t)
return list
zz = Permutation()
print(zz)
输出:
[123, 124, 132, 134, 142, 143, 213, 214, 231, 234, 241, 243, 312, 314, 321, 324, 341, 342, 412, 413, 421, 423, 431, 432]
初学菜鸟,希望有大佬能指点不足,感激不尽!
标签:各是,数字,菜鸟,list,三位数,range,zz,Permutation 来源: https://blog.csdn.net/wahaha07/article/details/116721235