Python How to loop a List
By:Roy.LiuLast updated:2019-08-17
In this tutorial, we will show you how to use for-in-loop to loop a List in Python.
#example 1 frameworks = ['flask', 'pyramid', 'django'] #list for temp in frameworks: print temp print "Python framework : %s" %temp #example 2 numbers = [2,4,6,8,10] #list for num in numbers: print num print "Number : %d" %num
Output
flask Python framework : flask pyramid Python framework : pyramid django Python framework : django Number : 2 Number : 4 Number : 6 Number : 8 10 Number : 10
References
From:一号门
Previous:Python How to split a String
COMMENTS