题解 | #字符串排序#

字符串排序

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

my_str = input()
new_str =''

for i in my_str:
    if i.isalpha():
        new_str += i

sort_str = sorted(new_str,key=str.upper)

index = 0
last_str = ''

for i in range(len(my_str)):
    if my_str[i].isalpha():
        last_str += sort_str[index]
        index += 1
    else:
        last_str += my_str[i]

print(last_str)

全部评论

相关推荐

01-19 15:14
已编辑
延安大学 C++
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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