I'm attempting to translate some PHP code to Python and I'm stuck on the 4th line in the following code (included for context):
$table = array();
for ($i = 0; $i < strlen($text); $i++) {
$char = substr($text, $i, $look_forward);
if (!isset($table[$char])) $table[$char] = array();
}
If array()
is used to create an array in PHP, what is $table[$char] = array()
doing? Creating a new array inside an existing array? Or is it extending the array?
What is this accomplishing? What would be the Python equivalent to this?
if (!isset($table[$char])) $table[$char] = array();