【checkio】Pawn Brotherhood(Home)

def safe_pawns(pawns):
    potential_position = []
    for val in pawns:
        temp_list = calc_cross(val)
        potential_position += temp_list
    count = [i in potential_position for i in pawns].count(True)

    return count

#斜めの位置のコマ位置を計算
def calc_cross(analyze_str):
    return_list = []
    
    for loop_cnt in range(2):
        if 0 < int(analyze_str[1]) < 8:
            if(ord(analyze_str[0]) == 97):
                data_1 = chr(ord(analyze_str[0])+1)
                data_2 = int(analyze_str[1]) + 1
                return_list.append(data_1 + str(data_2))
            if(ord(analyze_str[0]) == 122):
                data_1 = chr(ord(analyze_str[0])-1)
                data_2 = int(analyze_str[1]) + 1
                return_list.append(data_1 + str(data_2))
            else:
                data_1_1 = chr(ord(analyze_str[0])-1)
                data_1_2 = chr(ord(analyze_str[0])+1)
                data_2 = int(analyze_str[1]) + 1
                return_list.append(data_1_1 + str(data_2))
                return_list.append(data_1_2 + str(data_2))
    return return_list

if __name__ == '__main__':
    #These "asserts" using only for self-checking and not necessary for auto-testing
    assert safe_pawns({"b4", "d4", "f4", "c3", "e3", "g5", "d2"}) == 6
    assert safe_pawns({"b4", "c4", "d4", "e4", "f4", "g4", "e5"}) == 1
    print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")