(Dec-12-2017, 12:30 AM)Arcs Wrote: hopefully one day python can have a powerful foreach loop as it is in many ways my love letter to PHP
Not quite sure you understand that python HAS it...
i.e. your example in OP, is the same as printing key, value pairs from dict as already shown in previous posts, but anyway
PHP
$a = array('one'=>2,3=>4,5=>'six'); foreach($a as $k=>$v) echo "$k:$v\n";Python
a = {'one':2,3:4,5:'six'} for key, value in a.items(): print('{}:{}'.format(key, value))now if you want also the index, then you need enumerate
same apply for any other iterable. Actually this is the pythonic way, not using indexes