我正在研究作为 Google Python 类的一部分的 string1 练习。我遇到的问题是C:
C. fix_start
Given a string s, return a string
where all occurences of its first char have
been changed to '*', except do not change
the first char itself.
e.g. 'babble' yields 'ba**le'
Assume that the string is length 1 or more.
Hint: s.replace(stra, strb) returns a version of string s
where all instances of stra have been replaced by strb.
我正在考虑使用循环将每个字母与第一个字母进行比较,并用“*”替换任何匹配的字母。我认为必须有一个更简单的方法。有没有人有什么建议?