Python中for循环案例:数一数有几个a

name = "itheima is a brand of itcast"

count = 0

for x in name:

    if x == "a":
        count += 1

print(f"被统计的字符串中有{count}个a")
 
posted @ 2023-12-06 16:33  hugh2023  阅读(156)  评论(0)    收藏  举报