练习一:数学计算 有四个数字,分别是1,2,3,4,请问可以组成多少个相互不重复的数字,各是多少
题目:有四个数字,分别是1,2,3,4,请问可以组成多少个相互不重复的数字,各是多少
count = 0 list1 = [] for x in range(1,5): for y in range(1,5): for z in range(1,5): if x != y and y != z and x != z: count += 1 m = str(x)+str(y)+str(z) list1.append(m) print(count) print(list1)
答案:
24
['123', '124', '132', '134', '142', '143', '213', '214', '231', '234', '241', '243', '312', '314', '321', '324', '341', '342', '412', '413', '421', '423', '431', '432']