简体   繁体   English

如何用“*”替换以下出现的第一个字母?

[英]How do I replace the following occurrences of the first letter with a "*"?

I got stuck on this and I don't know what to do from here.我被困在这个问题上,我不知道该怎么做。

# 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 = 

for example: given string = 'bubble' it should return: bu**le例如:给定 string = 'bubble' 它应该返回:bu**le

def fix_start(s):
    return s[0]+ s[1:].replace(s[0],'*')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何替换字符串中第一个字母的所有实例,而不替换第一个字母本身 - How do I replace all instances of the first letter in a string, but not the first letter itself 如何将按字母顺序排列的最小字母替换为1,将下一个最小字母替换为2,但又不丢弃多次出现的字母? - how to replace the alphabetically smallest letter by 1, the next smallest by 2 but do not discard multiple occurrences of a letter? 如何打印单词的第一个字母? - How do I print the first letter of a word? 如何将字符串的最后一个字符替换为字母表的第一个字母? - How can I replace the last character of a string for the first letter of the alphabet? 如何小写我的部分网址地址的第一个字母? - How do I lowercase the first letter of part of my urls address? 如何打印 python 中每个字符串的第一个字母、第二个字母和第三个字母? - How do I print the first letter and second letter and third.. of each string in python? 如何获取我(如果在列表中为“输入”)检查输入的每个字母,而不仅仅是输入的第一个字母? - How do I get my (if “input” in list) to check every letter of the input and not just the first letter of input? 如何让我的代码将其中包含大写字母的单词的首字母大写? (猪拉丁语) - How do I make my code capitalize the first letter of the word that has a capital letter in it? (Pig Latin) 除了第一个和最后一个字母,如何替换字符串中每个字母的出现? - How do you replace every occurrence of a letter in a string apart from the first and the last ones? 如何使用正则表达式在字符串中查找一个字母及其相反的大小写? - How do I use Regex to find a letter and its opposite case one following the other in a string?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM