题目
代码
def AlterList(alist):
count = len(alist)
for i in range(count):
if alist[i] % 2 == 0:
alist[i] = int(alist[i] / 2)
else:
alist[i] = alist[i]** 2
return sorted(alist)
alist = list(map(int,input("Enter a list:
").split( )))
alter_list = AlterList(alist)
print(alter_list)
输入
1 2 3 4
输出
[1, 1, 2, 9]