Python3练习题 001:4个数字求不重复的3位数

时间:2023-03-08 17:27:10
#Python练习题 001:4个数字求不重复的3位数
#方法一
import itertools
res = []
[res.append(i[0]*100 + i[1]*10 + i[2]) for i in itertools.permutations(range(1,5),3)]
print(res, end = ',') """
参考
https://www.cnblogs.com/iderek/p/5952126.html
""" #方法二
for i in range(1,5):
for j in range(1,5):
for k in range(1,5):
if i!=j and i!=k and j!=k:
res=i*100+j*10+k
print(res, end='\t')
print()