python avoid nested for loops

welcome to shbcf.ru