python循环语句之for

2026-02-13 14:19:47

1、for循环的格式:

for 变量 in 列表或者字符串等:

      循环满足条件时执行的代码

else:

   循环不满足条件时执行的代码

   temp="zhangchong"

   for i in temp:

       print(i)

   else:

       print("没有数据")

-------------------------------------

   list1=['zhangchong','chong','hello','world']

   for i in list1:

       print(i)

  else:

      print("没有数据")

python循环语句之for

python循环语句之for

python循环语句之for

python循环语句之for

猜你喜欢