words = input().split() words.sort() print('After sorted:') for i in words: print(i)
这样写就可以了
print("After sorted:\n" + ("\n".join(sorted(input().split()))))