题解 | #表示数字#

表示数字

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

# !/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'tianyi'
__date__ = '2024/3/24 18:07 '
__file__ = 'HW_HJ96.py'

import sys
# 1. 读取输入
String1 = ""
x=0
for n in sys.stdin.readline().rstrip():
        if n.isdigit() and x == 0:
            String1+="*"+n
            x=1
        elif n.isdigit() and x == 1:
            String1 += n
        else:
            if x == 1:
                String1 += "*"+n
                x = 0
            else:
                String1 += n
#        if n is sys.stdin.readline().rstrip()[-1] and x == 1:
#            String1 += "*"

if String1[-1].isdigit():
    String1 += "*"
print(String1)

sys.stdin.readline().rstrip()[-1] 为什么超出index边界

全部评论

相关推荐

哈哈哈哈哈哈哈哈哈哈这个世界太美好了
凉风落木楚山秋:毕业出路老师不管,你盖个章他好交差就完事了,等你盖完毕业了就不关他事情了
点赞 评论 收藏
分享
面向对象的火龙果很爱...:去吃一顿炸鸡就走
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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