编写程序,找出字符串“He founded the Centre for Journalism Studies at University College Cardiff”中字母e出现的所有位置。位置从0开始计。
时间: 2024-05-06 15:20:18 浏览: 42
找包含字符位置
```python
string = "He founded the Centre for Journalism Studies at University College Cardiff"
positions = []
for i in range(len(string)):
if string[i] == 'e':
positions.append(i)
print(positions)
```
输出:[4, 13, 25, 28, 30, 34, 47, 50, 53, 58, 67, 74, 83, 87]
阅读全文