题解 | #字符串排序#

字符串排序

http://www.nowcoder.com/practice/5190a1db6f4f4ddb92fd9c365c944584

while True:
    try:
        a = list(input())
        lst = [i for i in a if i.isalpha()]
        lst.sort(key=str.upper)
        count = 0
        for i,v in enumerate(a):
            if v.isalpha():
                a[i] = lst[count]
                count +=1
        print(''.join(a))
                
    except:
        break

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务