jj[0]!=jj[2] and jj[1]!=jj[2]:去除任意两个数位上有相同的数字 (Tab)(Tab)listb.append(int(jj))print(listb)'''运行效果 [123, 124, 132, 134, 142, 143, 213, 214, 231, 234, 241, 243, 312, 314, 321, 324, 341, 342, 412, 413, 421, 423, 431, 432]'''
python求1234可以组成多少个互不相同且无重复数字三位数的三位数。
lista=[]
listb=[]
listx=[str(j) for j in range(5,10)]
listx.insert(0,"0")
'''(Tab)处缩进代码'''
for j in range(123, 433):
#确定范围123~432
(Tab)if str(j)[1] not in listx and str(j)[2] not in listx:
#排除三位数中各数位上数字是0、5、6、7、8、9
(Tab)(Tab)lista.append(str(j))
for jj in lista:
(Tab)if jj[0]!=jj[1] and jj[0]!=jj[2] and jj[1]!=jj[2]:
#去除任意两个数位上有相同的数字
(Tab)(Tab)listb.append(int(jj))
print(listb)
'''运行效果
[123, 124, 132, 134, 142, 143, 213, 214, 231, 234, 241, 243, 312, 314, 321, 324, 341, 342, 412, 413, 421, 423, 431, 432]
'''2022-11-17