Python Solution of strings and array part