题解 | #表示数字#

表示数字

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

全部评论

相关推荐

练习生懒羊羊:开飞机把这个公司创飞吧
点赞 评论 收藏
分享
头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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