for 循环 找name中有几个y
''' for循环 ''' name="fqs" for x in name: print(x)
'''
for循环输出name中有几个y
'''
name="yyyyygfdskkklliuyyhhhhhhhhhhhhuuuu"
i=1
for x in name:
print(x)
if x=="y":
i += 1
print("有"+str(i)+"个y")
range 左开右关
''' for循环 ''' for x in range(10): print(x) 结果 0123456789 从0开始,结尾不包含10
for x in range(5,10): print(x,end="")
结果 56789 从5开始,结尾不包含10
for x in range(5,10,2): print(x,end="")
结果 579 从5开始 步长为2 不包含10