本题要求编写程序,读入5个字符串,按由小到大的顺序输出。
输入为由空格分隔的5个非空字符串,每个字符串不包括空格、制表符、换行符等空白字符,长度小于80。
按照以下格式输出排序后的结果:
After sorted:
每行一个字符串
red yellow blue green white
After sorted:
blue
green
red
white
yellow
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
‘‘‘
@File : 第3章-11 字符串排序 .py
@Time : 2021/06/25 11:43:16
@Author : Gu Jiakai
@Contact : 2260016947@qq.com
@Department : Nanjing Xiaozhuang University
@Desc : None
‘‘‘
# here put the import lib
lst=list(input().split())
lst.sort()
print("After sorted:")
for i in lst:
print(i)
原文:https://www.cnblogs.com/gujiakai-top/p/14930365.html