昨天的知识点今天复习了一遍,感觉效果还不错奥! 案例题:数一数有几个字母a? count = 0name = "itheima is a brand of itcast"for x in name:if x == "a":count += 1print(count)#4 完结 🎉 继续更新 加个关注收藏一下叭~
定义字符串变量name,内容为:"itheima is a brand of itcast 通过for循环,遍历此字符串,统计有多少个英文字母:"a i=0name="itheima is a brand of itcast"for x in name:if x=='a':i+=1print(f"itheima is a brand of itcast中共含有:{i}个字母a")