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

#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()
posted @ 2018-06-02 14:05  点点花飞谢  阅读(898)  评论(0编辑  收藏  举报