题解 | #表示数字#

表示数字

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

全部评论

相关推荐

项目和八股忘了好多,后天就面试了,会脏面评嘛
一切顺利喵:我也春招被字节捞了,然后,全背八股了,面试全问的项目,全忘记了
点赞 评论 收藏
分享
小狗吃臭臭:差不多也就这样了,估计再多写也就是造假了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务