首页 > 解决方案 > Python - 从while循环到for循环

问题描述

如何制作一个 for 循环而不是这个 while 循环?

count = 2
data = ["string 1", "some quotation", "ugly phrase"]

while (count != len(data[0])):
    # Do some stuff
    count += 1

我正在看教程,但我无法弄清楚。

标签: python

解决方案


for count in range(2, len(data[0])):
    # code

推荐阅读