就是把这些三位数,放入同一个列表中
原来的要求输入三个数组成一个三位数,并全部列出来,求出最大值和最小值。
但是,我在所以三位数求出来后,不知道该怎么去找最大值了
正确的写法如下:
>>> from itertools import permutations as perm
>>> x = input('a,b,c的值:').split(',')
a,b,c的值:1,2,3
>>> print(x)
['1', '2', '3']
>>> y = list()
>>> for i in perm(x,3):
y.append(i)
>>> print(y)
[('1', '2', '3'), ('1', '3', '2'), ('2', '1', '3'), ('2', '3', '1'), ('3', '1', '2'), ('3', '2', '1')]
>>> y2 = list()
>>> for i in y:
y2.append(int(''.join(i)))
>>> print(y2)
[123, 132, 213, 231, 312, 321]
>>> max(y2)
321
>>> min(y2)
123
>>>