# coding=utf-8 result = [] #空列表用来存储满足条件的三位数 num = 0 # 用来记录满足条件的三位数的个数 for B in range(1,5): # B 百位数 for S in range(1,5): # S 十位数 for G in range(1,5): # G 个位数 if (B != S)and(B != G)and(S != G): num += 1 result.append(B*100 + S*10 + G) print(result) print(num)