【发布时间】:2022-11-29 09:19:43
【问题描述】:
race = "The rabbit will run with the turtle in the race."
if you == "race":
print("")
print("Here is example 1!, 'R' is the chosen letter")
print(race)
print(race[5:race.find("r")] + race[:race.rfind("r")+4].replace("r", "R", 4).replace("R","r",1))
我如何将 .count、.replace、.find、.rfind 实现到代码的最后一行,并使句子中字母 "r" 的第一个和最后一个实例保持小写,但中间两个"r"是大写吗?
预期输出:(使用 .count、.find、.rfind、.replace)
The rabbit will run with the turtle in the race.
The rabbit will Run with the tuRtle in the race.
【问题讨论】:
标签: python