题解 | #表示数字#

表示数字

http://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6

# -*-coding:utf-8-*-
import math , string

while True:
    try:
        str1 = input()
        str1_list = list(str1)
        str2_list = str1_list.copy()
        n = 0
        for i in range(0 , len(str1_list)):
            if (str1_list[i].isdigit() and i == 0):
                str2_list.insert(i , '*')
                n = n + 1
            if i < len(str1_list)-1:
                if (not str1_list[i].isdigit() and str1_list[i + 1].isdigit()) or \
                        (str1_list[i].isdigit() and not str1_list[i + 1].isdigit()):
                    str2_list.insert(i + n + 1 , '*')
                    n = n + 1
            if (str1_list[i].isdigit() and i==(len(str1_list)-1)):
                str2_list.insert(i + n +1 , '*')
        print("".join(str2_list))
    except:
        break

全部评论

相关推荐

2025-12-15 14:16
门头沟学院 Java
回家当保安:发offer的时候会背调学信网,最好不要这样。 “27届 ”和“28届以下 ”公司招聘的预期是不一样的。
实习简历求拷打
点赞 评论 收藏
分享
牛至超人:哈工大已经很棒了,不需要加括号了,然后咋没有实习经历呢?火速趁寒假整一段实习,导师不让就狠狠肘击
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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