I have the following PHP code, and for the life of me I can't think of a simple & elegant way to implement around the empty() function in python to check if the index is defined in a list.
$counter = 0;
$a = array();
for ($i=0;$i<100;$i++){
$i = ($i > 4) ? 0 : $i;
if empty($a[$i]){
$a[$i]=array();
}
$a[$i][] = $counter;
$counter++;
}
if I do
if a[i] is None
then I get index out of range. However I am aware of ways to do it in multiple steps, but that's not what I wanted.