GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Sunday, December 19, 2010

Python For Loop

For loop in Python is embed with list, and it's similar to foreach in PHP. This  for loop will iterate to all elements in the data structure:

>> cities = ["jakarta", "manila", "sydney"]    // list 
>> for value in cities:
>>     print value

This code will print out all chars in the string text:
>> for i in "Holla World":
>>     print i
Share/Bookmark

No comments:

Post a Comment