这是我到目前为止,但为了取代a,b和c,我想知道我如何能纳入取代所有3个字母在所有出现的句子。我也不允许使用replace()函数。你知道吗
def changeLetters(word):
for letter in word:
if letter == "a": #I would like to replace a,b and c
word.replace(letter,"!") #replace the replace() function
return word
用户输入示例:
Amy buys carrots and apples
用户输出示例:
!my 3uys 8!rrots !nd !pples
回答:
您可以修改或插入“if”语句以替换大写“A”,或根据需要为字母指定不同的替换字符。你知道吗
相关问题 更多 >
编程相关推荐