map through an array in python code example
Example 1: how to iterate through a map in c++
//traditional way (long)
for(map<string,int>::iterator it=m.begin(); it!=m.end(); ++it)
if(it->second)cout<<it->first<<" ";
//easy way(short) just works with c++11 or later versions
for(auto &x:m)
if(x.second)cout<<x.first<<" ";
//condition is just an example of use
Example 2: how to loop through list in python
thisList = [1, 2, 3, 4, 5, 6]
x = 0
while(x < len(thisList)):
print(thisList[x])
x += 1
# or you can do this:
for x in range(0, len(thisList)):
print(thisList[x])
#or you can do this
for x in thisList:
print(x)