You can use a for loop to traverse the list
In order to output each data in the list more efficiently, you can use a loop to complete
Example:
In [3]: list1=["zhang","qing","123",123,"zhang123"In [4]: for temp in list1: ...: print("遍历list1=%s"%temp) 遍历list1=zhang 遍历list1=qing 遍历list1=123 遍历list1=123 遍历list1=zhang123
You can also use while loop
In [9]: list1=["zhang","qing","123",345 In [10]: i=0 In [11]: while i<len(list1): ....: print(list1[i]) ....: i+=1 ....: zhang qing 123 345
Python tutorial column for learning!
The above is the detailed content of How to loop through a list in python. For more information, please follow other related articles on the PHP Chinese website!