count = 0 #计数器 for x in range(1,5): for y in range(1,5): for z in range(1,5): if x!=y and x!=z and y!=z: num=x*100+y*10+z print(num,end=' ') count += 1 print() print('无重复数字的三位数的个数:'+str(count)) #列推导式 num1 =[x*100+y*10+z for x in range(1,5) for y in range(1,5) for z in range(1,5) if x!=y and x!=z and y!=z] print(num1)