#while循环遍历列表
def list_while_func():
my_list=["a","b","c","d"]
index=0
while index<len(my_list):
# element=my_list[index]
print(my_list[index])
index+=1
list_while_func()
#for循环遍历列表元素
def list_for_func():
my_list=[1,1,1,1,3,4,4]
for element in my_list:
print(element)
list_for_func()
python 学习笔记014 遍历列表
最新推荐文章于 2024-09-12 08:54:42 发布
本文对比了Python中while和for循环在遍历列表的应用,展示了如何使用它们打印列表元素。
摘要由CSDN通过智能技术生成