[英]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.