代码:
a = input("请输入数字:").split()
b = list(map(int, a))
print("生成一个新的列表为:", b)
def new(c):
if c % 2 == 0:
return 2
else:
return 1
print("生成一个奇数在前偶数在后的列表为:", [a for a in sorted(sorted(b), key=new)])
运行结果:
代码:
a = input("请输入数字:").split()
b = list(map(int, a))
print("生成一个新的列表为:", b)
def new(c):
if c % 2 == 0:
return 2
else:
return 1
print("生成一个奇数在前偶数在后的列表为:", [a for a in sorted(sorted(b), key=new)])
运行结果: