题解 | #表示数字#

表示数字

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

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-23 14:22
点赞 评论 收藏
分享
07-19 13:28
长沙学院 Java
程序员小白条:你有面试就有希望,没面试自然就没希望,到时候就知道了,你问别人也没啥用处的
点赞 评论 收藏
分享
06-13 10:15
门头沟学院 Java
想去夏威夷的大西瓜在...:我也是27届,但是我现在研一下了啥项目都没有呀咋办,哎,简历不知道咋写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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