![](/img/trans.png)
[英]How do I replace all instances of the first letter in a string, but not the first letter itself
[英]How do I replace the following occurrences of the first letter with a "*"?
我被困在这个问题上,我不知道该怎么做。
# returns a string that changes all occurrences of its first char have been changed to '*'
def fix_start(str):
results = []
str.startswith(str[1])
results =
例如:给定 string = 'bubble' 它应该返回:bu**le
def fix_start(s):
return s[0]+ s[1:].replace(s[0],'*')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.