题解 | 字符串排序

字符串排序

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

s = input()
letters = [c for c in s if c.isalpha()]
sorted_l = sorted(letters,key=str.lower)
cnt = 0
res = ""
for i in range(0,len(s)):
    c = s[i]
    if c.isalpha():
        res = res + sorted_l[cnt]
        cnt = cnt + 1
    else:
        res = res + c
print(res)

全部评论

相关推荐

C9本港硕都给我挂了,好歹给个面试啊
丶西瓜:人太多,给他们惯的
投递海尔等公司9个岗位
点赞 评论 收藏
分享
柯柯想吃鱼:学的是物流工程,注意工程二字,而不是做仓管员自己技术完全没有用得上的实习,竞争力较弱,推荐找一个实习比如物流规划这种,需要用到cad的等等等,照这个思路
点赞 评论 收藏
分享
点赞 评论 收藏
分享
09-04 14:11
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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