""" 演示for循环的练习题:数一数有几个a """ # 统计如下字符串中,有多少个字母a name = "itheima is a brand of itcast" # 定义一个变量,用来统计有多少个a count = 0 # for 循环统计 # for 临时变量 in 被统计的数据: for x in name: if x == "a": count += 1 print(f"被统计的字符串中有{count}个a")