x = "i am a teacher,i am man, and i am 38 years old.I am not a businessman."其中有字母“I”误写为“i”,请编写程序进行纠正
时间: 2023-11-28 19:47:54 浏览: 76
九年级英语全册 Unit 10 By the time I got outside单元综合试题 人教新目标版
可以使用字符串的replace()方法来替换字符串中的字母。代码如下:
```python
x = "i am a teacher,i am man, and i am 38 years old.I am not a businessman."
x = x.replace("i", "I")
print(x)
```
运行结果:
```
I am a teacher,I am man, and I am 38 years old.I am not a businessman.
```
这样就把所有小写字母“i”替换成大写字母“I”了。
阅读全文